OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of resolution; | 5 part of resolution; |
6 | 6 |
7 abstract class TreeElements { | 7 abstract class TreeElements { |
8 Element operator[](Node node); | 8 Element operator[](Node node); |
9 Selector getSelector(Send send); | 9 Selector getSelector(Send send); |
10 DartType getType(Node node); | 10 DartType getType(Node node); |
(...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1041 Element resolveTypeName(Scope scope, TypeAnnotation node) { | 1041 Element resolveTypeName(Scope scope, TypeAnnotation node) { |
1042 Identifier typeName = node.typeName.asIdentifier(); | 1042 Identifier typeName = node.typeName.asIdentifier(); |
1043 Send send = node.typeName.asSend(); | 1043 Send send = node.typeName.asSend(); |
1044 return resolveTypeNameInternal(scope, typeName, send); | 1044 return resolveTypeNameInternal(scope, typeName, send); |
1045 } | 1045 } |
1046 | 1046 |
1047 Element resolveTypeNameInternal(Scope scope, Identifier typeName, Send send) { | 1047 Element resolveTypeNameInternal(Scope scope, Identifier typeName, Send send) { |
1048 if (send != null) { | 1048 if (send != null) { |
1049 typeName = send.selector; | 1049 typeName = send.selector; |
1050 } | 1050 } |
1051 if (identical(typeName.source.stringValue, 'void')) { | 1051 String stringValue = typeName.source.stringValue; |
| 1052 if (identical(stringValue, 'void')) { |
1052 return compiler.types.voidType.element; | 1053 return compiler.types.voidType.element; |
1053 } else if ( | 1054 } else if (identical(stringValue, 'Dynamic')) { |
1054 // TODO(aprelev@gmail.com): Remove deprecated Dynamic keyword support. | 1055 // TODO(aprelev@gmail.com): Remove deprecated Dynamic keyword support. |
1055 identical(typeName.source.stringValue, 'Dynamic') | 1056 compiler.onDeprecatedFeature(typeName, 'Dynamic'); |
1056 || identical(typeName.source.stringValue, 'dynamic')) { | 1057 return compiler.dynamicClass; |
| 1058 } else if (identical(stringValue, 'dynamic')) { |
1057 return compiler.dynamicClass; | 1059 return compiler.dynamicClass; |
1058 } else if (send != null) { | 1060 } else if (send != null) { |
1059 Element e = scope.lookup(send.receiver.asIdentifier().source); | 1061 Element e = scope.lookup(send.receiver.asIdentifier().source); |
1060 if (e != null && identical(e.kind, ElementKind.PREFIX)) { | 1062 if (e != null && identical(e.kind, ElementKind.PREFIX)) { |
1061 // The receiver is a prefix. Lookup in the imported members. | 1063 // The receiver is a prefix. Lookup in the imported members. |
1062 PrefixElement prefix = e; | 1064 PrefixElement prefix = e; |
1063 return prefix.lookupLocalMember(typeName.source); | 1065 return prefix.lookupLocalMember(typeName.source); |
1064 } else if (e != null && identical(e.kind, ElementKind.CLASS)) { | 1066 } else if (e != null && identical(e.kind, ElementKind.CLASS)) { |
1065 // The receiver is the class part of a named constructor. | 1067 // The receiver is the class part of a named constructor. |
1066 return e; | 1068 return e; |
(...skipping 1852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2919 Link<Element> parameters = const Link<Element>(); | 2921 Link<Element> parameters = const Link<Element>(); |
2920 int requiredParameterCount = 0; | 2922 int requiredParameterCount = 0; |
2921 if (formalParameters == null) { | 2923 if (formalParameters == null) { |
2922 if (!element.isGetter()) { | 2924 if (!element.isGetter()) { |
2923 compiler.reportMessage(compiler.spanFromElement(element), | 2925 compiler.reportMessage(compiler.spanFromElement(element), |
2924 MessageKind.MISSING_FORMALS.error([]), | 2926 MessageKind.MISSING_FORMALS.error([]), |
2925 Diagnostic.ERROR); | 2927 Diagnostic.ERROR); |
2926 } | 2928 } |
2927 } else { | 2929 } else { |
2928 if (element.isGetter()) { | 2930 if (element.isGetter()) { |
2929 if (!element.getLibrary().isPlatformLibrary) { | 2931 if (!identical(formalParameters.getEndToken().next.stringValue, |
2930 // TODO(ahe): Remove the isPlatformLibrary check. | 2932 // TODO(ahe): Remove the check for native keyword. |
2931 if (!identical(formalParameters.getEndToken().next.stringValue, 'nativ
e')) { | 2933 'native')) { |
2932 // TODO(ahe): Remove the check for native keyword. | 2934 if (compiler.rejectDeprecatedFeatures && |
| 2935 // TODO(ahe): Remove isPlatformLibrary check. |
| 2936 !element.getLibrary().isPlatformLibrary) { |
2933 compiler.reportMessage(compiler.spanFromNode(formalParameters), | 2937 compiler.reportMessage(compiler.spanFromNode(formalParameters), |
2934 MessageKind.EXTRA_FORMALS.error([]), | 2938 MessageKind.EXTRA_FORMALS.error([]), |
2935 Diagnostic.WARNING); | 2939 Diagnostic.ERROR); |
| 2940 } else { |
| 2941 compiler.onDeprecatedFeature(formalParameters, 'getter parameters'); |
2936 } | 2942 } |
2937 } | 2943 } |
2938 } | 2944 } |
2939 LinkBuilder<Element> parametersBuilder = | 2945 LinkBuilder<Element> parametersBuilder = |
2940 visitor.analyzeNodes(formalParameters.nodes); | 2946 visitor.analyzeNodes(formalParameters.nodes); |
2941 requiredParameterCount = parametersBuilder.length; | 2947 requiredParameterCount = parametersBuilder.length; |
2942 parameters = parametersBuilder.toLink(); | 2948 parameters = parametersBuilder.toLink(); |
2943 } | 2949 } |
2944 DartType returnType = compiler.resolveReturnType(element, returnNode); | 2950 DartType returnType = compiler.resolveReturnType(element, returnNode); |
2945 return new FunctionSignature(parameters, | 2951 return new FunctionSignature(parameters, |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3114 return e; | 3120 return e; |
3115 } | 3121 } |
3116 | 3122 |
3117 /// Assumed to be called by [resolveRedirectingFactory]. | 3123 /// Assumed to be called by [resolveRedirectingFactory]. |
3118 Element visitReturn(Return node) { | 3124 Element visitReturn(Return node) { |
3119 Node expression = node.expression; | 3125 Node expression = node.expression; |
3120 return finishConstructorReference(visit(expression), | 3126 return finishConstructorReference(visit(expression), |
3121 expression, expression); | 3127 expression, expression); |
3122 } | 3128 } |
3123 } | 3129 } |
OLD | NEW |