| Index: pkg/analyzer_experimental/lib/src/generated/resolver.dart
|
| diff --git a/pkg/analyzer-experimental/lib/src/generated/resolver.dart b/pkg/analyzer_experimental/lib/src/generated/resolver.dart
|
| similarity index 95%
|
| rename from pkg/analyzer-experimental/lib/src/generated/resolver.dart
|
| rename to pkg/analyzer_experimental/lib/src/generated/resolver.dart
|
| index bee446b2cbbd57bedcc72988650015c839c045ea..aba27db54eb7125e24ddc5124b337a1b218d7e58 100644
|
| --- a/pkg/analyzer-experimental/lib/src/generated/resolver.dart
|
| +++ b/pkg/analyzer_experimental/lib/src/generated/resolver.dart
|
| @@ -15,6 +15,7 @@ import 'parser.dart' show Parser;
|
| import 'element.dart' hide HideCombinator, ShowCombinator;
|
| import 'html.dart' as ht;
|
| import 'engine.dart';
|
| +import 'constant.dart';
|
| import 'element.dart' as __imp_combi show HideCombinator, ShowCombinator;
|
|
|
| /**
|
| @@ -172,6 +173,7 @@ class ElementBuilder extends RecursiveASTVisitor<Object> {
|
| element.labels = holder.labels;
|
| element.localVariables = holder.localVariables;
|
| element.parameters = holder.parameters;
|
| + element.const2 = node.constKeyword != null;
|
| _currentHolder.addConstructor(element);
|
| node.element = element;
|
| if (constructorName != null) {
|
| @@ -187,7 +189,7 @@ class ElementBuilder extends RecursiveASTVisitor<Object> {
|
| int declarationEnd = node.offset + node.length;
|
| int statementEnd = statement.offset + statement.length;
|
| element.setVisibleRange(declarationEnd, statementEnd - declarationEnd - 1);
|
| - element.const2 = matches(keyword27, sc.Keyword.CONST);
|
| + element.const3 = matches(keyword27, sc.Keyword.CONST);
|
| element.final2 = matches(keyword27, sc.Keyword.FINAL);
|
| _currentHolder.addLocalVariable(element);
|
| variableName.element = element;
|
| @@ -202,8 +204,13 @@ class ElementBuilder extends RecursiveASTVisitor<Object> {
|
| initializer.localVariables = holder.localVariables;
|
| initializer.parameters = holder.parameters;
|
| SimpleIdentifier parameterName = node.parameter.identifier;
|
| - ParameterElementImpl parameter = new ParameterElementImpl(parameterName);
|
| - parameter.const2 = node.isConst();
|
| + ParameterElementImpl parameter;
|
| + if (node.isConst()) {
|
| + parameter = new ConstParameterElementImpl(parameterName);
|
| + parameter.const3 = true;
|
| + } else {
|
| + parameter = new ParameterElementImpl(parameterName);
|
| + }
|
| parameter.final2 = node.isFinal();
|
| parameter.initializer = initializer;
|
| parameter.parameterKind = node.kind;
|
| @@ -230,7 +237,7 @@ class ElementBuilder extends RecursiveASTVisitor<Object> {
|
| if (node.parent is! DefaultFormalParameter) {
|
| SimpleIdentifier parameterName = node.identifier;
|
| ParameterElementImpl parameter = new ParameterElementImpl(parameterName);
|
| - parameter.const2 = node.isConst();
|
| + parameter.const3 = node.isConst();
|
| parameter.initializingFormal = true;
|
| parameter.final2 = node.isFinal();
|
| parameter.parameterKind = node.kind;
|
| @@ -337,7 +344,7 @@ class ElementBuilder extends RecursiveASTVisitor<Object> {
|
| SimpleIdentifier aliasName = node.name;
|
| List<ParameterElement> parameters10 = holder.parameters;
|
| List<TypeVariableElement> typeVariables6 = holder.typeVariables;
|
| - TypeAliasElementImpl element = new TypeAliasElementImpl(aliasName);
|
| + FunctionTypeAliasElementImpl element = new FunctionTypeAliasElementImpl(aliasName);
|
| element.parameters = parameters10;
|
| element.typeVariables = typeVariables6;
|
| FunctionTypeImpl type = new FunctionTypeImpl.con2(element);
|
| @@ -434,7 +441,7 @@ class ElementBuilder extends RecursiveASTVisitor<Object> {
|
| if (node.parent is! DefaultFormalParameter) {
|
| SimpleIdentifier parameterName = node.identifier;
|
| ParameterElementImpl parameter = new ParameterElementImpl(parameterName);
|
| - parameter.const2 = node.isConst();
|
| + parameter.const3 = node.isConst();
|
| parameter.final2 = node.isFinal();
|
| parameter.parameterKind = node.kind;
|
| _currentHolder.addParameter(parameter);
|
| @@ -474,33 +481,52 @@ class ElementBuilder extends RecursiveASTVisitor<Object> {
|
| return super.visitTypeParameter(node);
|
| }
|
| Object visitVariableDeclaration(VariableDeclaration node) {
|
| + sc.Token keyword28 = ((node.parent as VariableDeclarationList)).keyword;
|
| + bool isConst = matches(keyword28, sc.Keyword.CONST);
|
| + bool isFinal = matches(keyword28, sc.Keyword.FINAL);
|
| + bool hasInitializer = node.initializer != null;
|
| VariableElementImpl element;
|
| if (_inFieldContext) {
|
| SimpleIdentifier fieldName = node.name;
|
| - FieldElementImpl field = new FieldElementImpl.con1(fieldName);
|
| + FieldElementImpl field;
|
| + if (isConst && hasInitializer) {
|
| + field = new ConstFieldElementImpl(fieldName);
|
| + } else {
|
| + field = new FieldElementImpl.con1(fieldName);
|
| + }
|
| element = field;
|
| _currentHolder.addField(field);
|
| fieldName.element = field;
|
| } else if (_inFunction) {
|
| SimpleIdentifier variableName = node.name;
|
| - element = new LocalVariableElementImpl(variableName);
|
| + LocalVariableElementImpl variable;
|
| + if (isConst && hasInitializer) {
|
| + variable = new ConstLocalVariableElementImpl(variableName);
|
| + } else {
|
| + variable = new LocalVariableElementImpl(variableName);
|
| + }
|
| + element = variable;
|
| Block enclosingBlock = node.getAncestor(Block);
|
| int functionEnd = node.offset + node.length;
|
| int blockEnd = enclosingBlock.offset + enclosingBlock.length;
|
| - ((element as LocalVariableElementImpl)).setVisibleRange(functionEnd, blockEnd - functionEnd - 1);
|
| - _currentHolder.addLocalVariable((element as LocalVariableElementImpl));
|
| + variable.setVisibleRange(functionEnd, blockEnd - functionEnd - 1);
|
| + _currentHolder.addLocalVariable(variable);
|
| variableName.element = element;
|
| } else {
|
| SimpleIdentifier variableName = node.name;
|
| - element = new TopLevelVariableElementImpl.con1(variableName);
|
| - _currentHolder.addTopLevelVariable((element as TopLevelVariableElementImpl));
|
| + TopLevelVariableElementImpl variable;
|
| + if (isConst && hasInitializer) {
|
| + variable = new ConstTopLevelVariableElementImpl(variableName);
|
| + } else {
|
| + variable = new TopLevelVariableElementImpl.con1(variableName);
|
| + }
|
| + element = variable;
|
| + _currentHolder.addTopLevelVariable(variable);
|
| variableName.element = element;
|
| }
|
| - sc.Token keyword28 = ((node.parent as VariableDeclarationList)).keyword;
|
| - bool isFinal = matches(keyword28, sc.Keyword.FINAL);
|
| - element.const2 = matches(keyword28, sc.Keyword.CONST);
|
| + element.const3 = isConst;
|
| element.final2 = isFinal;
|
| - if (node.initializer != null) {
|
| + if (hasInitializer) {
|
| ElementHolder holder = new ElementHolder();
|
| bool wasInFieldContext = _inFieldContext;
|
| _inFieldContext = false;
|
| @@ -616,7 +642,7 @@ class ElementHolder {
|
| List<LabelElement> _labels = new List<LabelElement>();
|
| List<VariableElement> _localVariables = new List<VariableElement>();
|
| List<MethodElement> _methods = new List<MethodElement>();
|
| - List<TypeAliasElement> _typeAliases = new List<TypeAliasElement>();
|
| + List<FunctionTypeAliasElement> _typeAliases = new List<FunctionTypeAliasElement>();
|
| List<ParameterElement> _parameters = new List<ParameterElement>();
|
| List<VariableElement> _topLevelVariables = new List<VariableElement>();
|
| List<ClassElement> _types = new List<ClassElement>();
|
| @@ -656,7 +682,7 @@ class ElementHolder {
|
| void addType(ClassElement element) {
|
| _types.add(element);
|
| }
|
| - void addTypeAlias(TypeAliasElement element) {
|
| + void addTypeAlias(FunctionTypeAliasElement element) {
|
| _typeAliases.add(element);
|
| }
|
| void addTypeVariable(TypeVariableElement element) {
|
| @@ -679,7 +705,7 @@ class ElementHolder {
|
| List<MethodElement> get methods => new List.from(_methods);
|
| List<ParameterElement> get parameters => new List.from(_parameters);
|
| List<TopLevelVariableElement> get topLevelVariables => new List.from(_topLevelVariables);
|
| - List<TypeAliasElement> get typeAliases => new List.from(_typeAliases);
|
| + List<FunctionTypeAliasElement> get typeAliases => new List.from(_typeAliases);
|
| List<ClassElement> get types => new List.from(_types);
|
| List<TypeVariableElement> get typeVariables => new List.from(_typeVariables);
|
| }
|
| @@ -882,7 +908,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| operator7 = operatorFromCompoundAssignment(operator7);
|
| Expression leftNode = node.leftHandSide;
|
| if (leftNode != null) {
|
| - Type2 leftType = leftNode.staticType;
|
| + Type2 leftType = getType(leftNode);
|
| if (leftType != null) {
|
| Element leftElement = leftType.element;
|
| if (leftElement != null) {
|
| @@ -962,9 +988,9 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| return null;
|
| }
|
| Object visitExportDirective(ExportDirective node) {
|
| - Element element21 = node.element;
|
| - if (element21 is ExportElement) {
|
| - resolveCombinators(((element21 as ExportElement)).exportedLibrary, node.combinators);
|
| + Element element22 = node.element;
|
| + if (element22 is ExportElement) {
|
| + resolveCombinators(((element22 as ExportElement)).exportedLibrary, node.combinators);
|
| }
|
| return null;
|
| }
|
| @@ -980,9 +1006,9 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| }
|
| }
|
| }
|
| - Element element22 = node.element;
|
| - if (element22 is ImportElement) {
|
| - resolveCombinators(((element22 as ImportElement)).importedLibrary, node.combinators);
|
| + Element element23 = node.element;
|
| + if (element23 is ImportElement) {
|
| + resolveCombinators(((element23 as ImportElement)).importedLibrary, node.combinators);
|
| }
|
| return null;
|
| }
|
| @@ -1026,7 +1052,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| FunctionType getterType = getter.type;
|
| if (getterType != null) {
|
| Type2 returnType4 = getterType.returnType;
|
| - if (!returnType4.isDynamic() && returnType4 is! FunctionType && !returnType4.isDartCoreFunction()) {
|
| + if (!isExecutableType(returnType4)) {
|
| _resolver.reportError(StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION, methodName2, [methodName2.name]);
|
| }
|
| }
|
| @@ -1040,10 +1066,11 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| if (targetType is InterfaceType) {
|
| element = lookUpMethod(targetType.element, methodName2.name);
|
| if (element == null) {
|
| - PropertyAccessorElement accessor = lookUpGetterInType((targetType.element as ClassElement), methodName2.name);
|
| + ClassElement targetClass = targetType.element as ClassElement;
|
| + PropertyAccessorElement accessor = lookUpGetterInType(targetClass, methodName2.name);
|
| if (accessor != null) {
|
| - Type2 returnType5 = accessor.type.returnType;
|
| - if (!returnType5.isDynamic() && returnType5 is! FunctionType && !returnType5.isDartCoreFunction()) {
|
| + Type2 returnType5 = accessor.type.returnType.substitute2(((targetType as InterfaceType)).typeArguments, TypeVariableTypeImpl.getTypes(targetClass.typeVariables));
|
| + if (!isExecutableType(returnType5)) {
|
| _resolver.reportError(StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION, methodName2, [methodName2.name]);
|
| return null;
|
| }
|
| @@ -1076,7 +1103,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| FunctionType getterType = getter3.type;
|
| if (getterType != null) {
|
| Type2 returnType6 = getterType.returnType;
|
| - if (!returnType6.isDynamic() && returnType6 is! FunctionType && !returnType6.isDartCoreFunction()) {
|
| + if (!isExecutableType(returnType6)) {
|
| _resolver.reportError(StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION, methodName2, [methodName2.name]);
|
| }
|
| }
|
| @@ -1084,7 +1111,7 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| return null;
|
| } else if (element is VariableElement) {
|
| Type2 variableType = ((element as VariableElement)).type;
|
| - if (!variableType.isDynamic() && variableType is! FunctionType && !variableType.isDartCoreFunction()) {
|
| + if (!isExecutableType(variableType)) {
|
| _resolver.reportError(StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION, methodName2, [methodName2.name]);
|
| }
|
| recordResolution(methodName2, element);
|
| @@ -1383,6 +1410,13 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| return expression.staticType;
|
| }
|
| /**
|
| + * Return {@code true} if the given type represents an object that could be invoked using the call
|
| + * operator '()'.
|
| + * @param type the type being tested
|
| + * @return {@code true} if the given type represents an object that could be invoked
|
| + */
|
| + bool isExecutableType(Type2 type) => type.isDynamic() || (type is FunctionType) || type.isDartCoreFunction();
|
| + /**
|
| * Look up the getter with the given name in the given type. Return the element representing the
|
| * getter that was found, or {@code null} if there is no getter with the given name.
|
| * @param element the element representing the type in which the getter is defined
|
| @@ -1664,9 +1698,9 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| * @param node the AST node that was resolved
|
| * @param element the element to which the AST node was resolved
|
| */
|
| - void recordResolution(SimpleIdentifier node, Element element49) {
|
| - if (element49 != null) {
|
| - node.element = element49;
|
| + void recordResolution(SimpleIdentifier node, Element element52) {
|
| + if (element52 != null) {
|
| + node.element = element52;
|
| }
|
| }
|
| /**
|
| @@ -1736,15 +1770,15 @@ class ElementResolver extends SimpleASTVisitor<Object> {
|
| * @return the class that should be used in place of the argument if it is a type variable, or the
|
| * original argument if it isn't a type variable
|
| */
|
| - Element resolveTypeVariable(Element element50) {
|
| - if (element50 is TypeVariableElement) {
|
| - Type2 bound4 = ((element50 as TypeVariableElement)).bound;
|
| + Element resolveTypeVariable(Element element53) {
|
| + if (element53 is TypeVariableElement) {
|
| + Type2 bound4 = ((element53 as TypeVariableElement)).bound;
|
| if (bound4 == null) {
|
| return _resolver.typeProvider.objectType.element;
|
| }
|
| return bound4.element;
|
| }
|
| - return element50;
|
| + return element53;
|
| }
|
| }
|
| class Identifier_4 extends Identifier {
|
| @@ -2172,10 +2206,10 @@ class LibraryResolver {
|
| * @param analysisContext the analysis context in which the library is being analyzed
|
| */
|
| LibraryResolver.con1(AnalysisContextImpl analysisContext) {
|
| - _jtd_constructor_226_impl(analysisContext);
|
| + _jtd_constructor_237_impl(analysisContext);
|
| }
|
| - _jtd_constructor_226_impl(AnalysisContextImpl analysisContext) {
|
| - _jtd_constructor_227_impl(analysisContext, null);
|
| + _jtd_constructor_237_impl(AnalysisContextImpl analysisContext) {
|
| + _jtd_constructor_238_impl(analysisContext, null);
|
| }
|
| /**
|
| * Initialize a newly created library resolver to resolve libraries within the given context.
|
| @@ -2183,9 +2217,9 @@ class LibraryResolver {
|
| * @param errorListener the listener to which analysis errors will be reported
|
| */
|
| LibraryResolver.con2(AnalysisContextImpl analysisContext2, AnalysisErrorListener additionalAnalysisErrorListener) {
|
| - _jtd_constructor_227_impl(analysisContext2, additionalAnalysisErrorListener);
|
| + _jtd_constructor_238_impl(analysisContext2, additionalAnalysisErrorListener);
|
| }
|
| - _jtd_constructor_227_impl(AnalysisContextImpl analysisContext2, AnalysisErrorListener additionalAnalysisErrorListener) {
|
| + _jtd_constructor_238_impl(AnalysisContextImpl analysisContext2, AnalysisErrorListener additionalAnalysisErrorListener) {
|
| this._analysisContext = analysisContext2;
|
| this._recordingErrorListener = new RecordingErrorListener();
|
| if (additionalAnalysisErrorListener == null) {
|
| @@ -2989,9 +3023,9 @@ abstract class ScopedVisitor extends GeneralizingASTVisitor<Object> {
|
| }
|
| Object visitVariableDeclaration(VariableDeclaration node) {
|
| if (node.parent.parent is! TopLevelVariableDeclaration && node.parent.parent is! FieldDeclaration) {
|
| - VariableElement element23 = node.element;
|
| - if (element23 != null) {
|
| - _nameScope.define(element23);
|
| + VariableElement element24 = node.element;
|
| + if (element24 != null) {
|
| + _nameScope.define(element24);
|
| }
|
| }
|
| super.visitVariableDeclaration(node);
|
| @@ -3332,9 +3366,9 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| Object visitListLiteral(ListLiteral node) {
|
| TypeArgumentList typeArguments8 = node.typeArguments;
|
| if (typeArguments8 != null) {
|
| - NodeList<TypeName> arguments3 = typeArguments8.arguments;
|
| - if (arguments3 != null && arguments3.length == 1) {
|
| - TypeName argumentType = arguments3[0];
|
| + NodeList<TypeName> arguments4 = typeArguments8.arguments;
|
| + if (arguments4 != null && arguments4.length == 1) {
|
| + TypeName argumentType = arguments4[0];
|
| return recordType(node, _typeProvider.listType.substitute5(<Type2> [getType3(argumentType)]));
|
| }
|
| }
|
| @@ -3355,12 +3389,12 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| Object visitMapLiteral(MapLiteral node) {
|
| TypeArgumentList typeArguments9 = node.typeArguments;
|
| if (typeArguments9 != null) {
|
| - NodeList<TypeName> arguments4 = typeArguments9.arguments;
|
| - if (arguments4 != null && arguments4.length == 2) {
|
| - TypeName keyType = arguments4[0];
|
| + NodeList<TypeName> arguments5 = typeArguments9.arguments;
|
| + if (arguments5 != null && arguments5.length == 2) {
|
| + TypeName keyType = arguments5[0];
|
| if (keyType != _typeProvider.stringType) {
|
| }
|
| - TypeName valueType = arguments4[1];
|
| + TypeName valueType = arguments5[1];
|
| return recordType(node, _typeProvider.mapType.substitute5(<Type2> [_typeProvider.stringType, getType3(valueType)]));
|
| }
|
| }
|
| @@ -3442,17 +3476,17 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| */
|
| Object visitPrefixedIdentifier(PrefixedIdentifier node) {
|
| SimpleIdentifier prefixedIdentifier = node.identifier;
|
| - Element element24 = prefixedIdentifier.element;
|
| - if (element24 is VariableElement) {
|
| - Type2 variableType = ((element24 as VariableElement)).type;
|
| + Element element25 = prefixedIdentifier.element;
|
| + if (element25 is VariableElement) {
|
| + Type2 variableType = ((element25 as VariableElement)).type;
|
| recordType(prefixedIdentifier, variableType);
|
| return recordType(node, variableType);
|
| - } else if (element24 is PropertyAccessorElement) {
|
| - Type2 propertyType = getType2((element24 as PropertyAccessorElement));
|
| + } else if (element25 is PropertyAccessorElement) {
|
| + Type2 propertyType = getType2((element25 as PropertyAccessorElement));
|
| recordType(prefixedIdentifier, propertyType);
|
| return recordType(node, propertyType);
|
| - } else if (element24 is MethodElement) {
|
| - Type2 returnType = ((element24 as MethodElement)).type;
|
| + } else if (element25 is MethodElement) {
|
| + Type2 returnType = ((element25 as MethodElement)).type;
|
| recordType(prefixedIdentifier, returnType);
|
| return recordType(node, returnType);
|
| } else {
|
| @@ -3517,13 +3551,13 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| */
|
| Object visitPropertyAccess(PropertyAccess node) {
|
| SimpleIdentifier propertyName2 = node.propertyName;
|
| - Element element25 = propertyName2.element;
|
| - if (element25 is MethodElement) {
|
| - FunctionType type15 = ((element25 as MethodElement)).type;
|
| + Element element26 = propertyName2.element;
|
| + if (element26 is MethodElement) {
|
| + FunctionType type15 = ((element26 as MethodElement)).type;
|
| recordType(propertyName2, type15);
|
| return recordType(node, type15);
|
| - } else if (element25 is PropertyAccessorElement) {
|
| - Type2 propertyType = getType2((element25 as PropertyAccessorElement));
|
| + } else if (element26 is PropertyAccessorElement) {
|
| + Type2 propertyType = getType2((element26 as PropertyAccessorElement));
|
| recordType(propertyName2, propertyType);
|
| return recordType(node, propertyType);
|
| } else {
|
| @@ -3574,27 +3608,27 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| * </blockquote>
|
| */
|
| Object visitSimpleIdentifier(SimpleIdentifier node) {
|
| - Element element26 = node.element;
|
| - if (element26 == null) {
|
| + Element element27 = node.element;
|
| + if (element27 == null) {
|
| return recordType(node, _dynamicType);
|
| - } else if (element26 is ClassElement) {
|
| - if (isTypeName(node)) {
|
| - return recordType(node, ((element26 as ClassElement)).type);
|
| + } else if (element27 is ClassElement) {
|
| + if (isNotTypeLiteral(node)) {
|
| + return recordType(node, ((element27 as ClassElement)).type);
|
| }
|
| return recordType(node, _typeProvider.typeType);
|
| - } else if (element26 is TypeVariableElement) {
|
| - return recordType(node, ((element26 as TypeVariableElement)).type);
|
| - } else if (element26 is TypeAliasElement) {
|
| - return recordType(node, ((element26 as TypeAliasElement)).type);
|
| - } else if (element26 is VariableElement) {
|
| - return recordType(node, ((element26 as VariableElement)).type);
|
| - } else if (element26 is MethodElement) {
|
| - return recordType(node, ((element26 as MethodElement)).type);
|
| - } else if (element26 is PropertyAccessorElement) {
|
| - return recordType(node, getType2((element26 as PropertyAccessorElement)));
|
| - } else if (element26 is ExecutableElement) {
|
| - return recordType(node, ((element26 as ExecutableElement)).type);
|
| - } else if (element26 is PrefixElement) {
|
| + } else if (element27 is TypeVariableElement) {
|
| + return recordType(node, ((element27 as TypeVariableElement)).type);
|
| + } else if (element27 is FunctionTypeAliasElement) {
|
| + return recordType(node, ((element27 as FunctionTypeAliasElement)).type);
|
| + } else if (element27 is VariableElement) {
|
| + return recordType(node, ((element27 as VariableElement)).type);
|
| + } else if (element27 is MethodElement) {
|
| + return recordType(node, ((element27 as MethodElement)).type);
|
| + } else if (element27 is PropertyAccessorElement) {
|
| + return recordType(node, getType2((element27 as PropertyAccessorElement)));
|
| + } else if (element27 is ExecutableElement) {
|
| + return recordType(node, ((element27 as ExecutableElement)).type);
|
| + } else if (element27 is PrefixElement) {
|
| return null;
|
| } else {
|
| return recordType(node, _dynamicType);
|
| @@ -3710,13 +3744,13 @@ class StaticTypeAnalyzer extends SimpleASTVisitor<Object> {
|
| return type16;
|
| }
|
| /**
|
| - * Return {@code true} if the given node is being used as the name of a type.
|
| + * Return {@code true} if the given node is not a type literal.
|
| * @param node the node being tested
|
| - * @return {@code true} if the given node is being used as the name of a type
|
| + * @return {@code true} if the given node is not a type literal
|
| */
|
| - bool isTypeName(SimpleIdentifier node) {
|
| + bool isNotTypeLiteral(SimpleIdentifier node) {
|
| ASTNode parent15 = node.parent;
|
| - return parent15 is TypeName || (parent15 is PrefixedIdentifier && parent15.parent is TypeName) || (parent15 is MethodInvocation && identical(node, ((parent15 as MethodInvocation)).target));
|
| + return parent15 is TypeName || (parent15 is PrefixedIdentifier && (parent15.parent is TypeName || identical(((parent15 as PrefixedIdentifier)).prefix, node))) || (parent15 is PropertyAccess && identical(((parent15 as PropertyAccess)).target, node)) || (parent15 is MethodInvocation && identical(node, ((parent15 as MethodInvocation)).target));
|
| }
|
| /**
|
| * Record that the static type of the given node is the type of the second argument to the method
|
| @@ -4021,9 +4055,9 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| exceptionType = getType4(exceptionTypeName);
|
| }
|
| recordType(exception, exceptionType);
|
| - Element element27 = exception.element;
|
| - if (element27 is VariableElementImpl) {
|
| - ((element27 as VariableElementImpl)).type = exceptionType;
|
| + Element element28 = exception.element;
|
| + if (element28 is VariableElementImpl) {
|
| + ((element28 as VariableElementImpl)).type = exceptionType;
|
| } else {
|
| }
|
| }
|
| @@ -4071,11 +4105,11 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| }
|
| Object visitConstructorDeclaration(ConstructorDeclaration node) {
|
| super.visitConstructorDeclaration(node);
|
| - ExecutableElementImpl element28 = node.element as ExecutableElementImpl;
|
| - FunctionTypeImpl type = new FunctionTypeImpl.con1(element28);
|
| - setTypeInformation(type, null, element28.parameters);
|
| - type.returnType = ((element28.enclosingElement as ClassElement)).type;
|
| - element28.type = type;
|
| + ExecutableElementImpl element29 = node.element as ExecutableElementImpl;
|
| + FunctionTypeImpl type = new FunctionTypeImpl.con1(element29);
|
| + setTypeInformation(type, null, element29.parameters);
|
| + type.returnType = ((element29.enclosingElement as ClassElement)).type;
|
| + element29.type = type;
|
| return null;
|
| }
|
| Object visitDeclaredIdentifier(DeclaredIdentifier node) {
|
| @@ -4087,8 +4121,8 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| } else {
|
| declaredType = getType4(typeName);
|
| }
|
| - LocalVariableElementImpl element29 = node.element as LocalVariableElementImpl;
|
| - element29.type = declaredType;
|
| + LocalVariableElementImpl element30 = node.element as LocalVariableElementImpl;
|
| + element30.type = declaredType;
|
| return null;
|
| }
|
| Object visitDefaultFormalParameter(DefaultFormalParameter node) {
|
| @@ -4097,9 +4131,9 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| }
|
| Object visitFieldFormalParameter(FieldFormalParameter node) {
|
| super.visitFieldFormalParameter(node);
|
| - Element element30 = node.identifier.element;
|
| - if (element30 is ParameterElementImpl) {
|
| - ParameterElementImpl parameter = element30 as ParameterElementImpl;
|
| + Element element31 = node.identifier.element;
|
| + if (element31 is ParameterElementImpl) {
|
| + ParameterElementImpl parameter = element31 as ParameterElementImpl;
|
| Type2 type;
|
| TypeName typeName = node.type;
|
| if (typeName == null) {
|
| @@ -4114,35 +4148,35 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| }
|
| Object visitFunctionDeclaration(FunctionDeclaration node) {
|
| super.visitFunctionDeclaration(node);
|
| - ExecutableElementImpl element31 = node.element as ExecutableElementImpl;
|
| - FunctionTypeImpl type = new FunctionTypeImpl.con1(element31);
|
| - setTypeInformation(type, node.returnType, element31.parameters);
|
| - element31.type = type;
|
| + ExecutableElementImpl element32 = node.element as ExecutableElementImpl;
|
| + FunctionTypeImpl type = new FunctionTypeImpl.con1(element32);
|
| + setTypeInformation(type, node.returnType, element32.parameters);
|
| + element32.type = type;
|
| return null;
|
| }
|
| Object visitFunctionTypeAlias(FunctionTypeAlias node) {
|
| super.visitFunctionTypeAlias(node);
|
| - TypeAliasElementImpl element32 = node.element as TypeAliasElementImpl;
|
| - FunctionTypeImpl type18 = element32.type as FunctionTypeImpl;
|
| - setTypeInformation(type18, node.returnType, element32.parameters);
|
| + FunctionTypeAliasElementImpl element33 = node.element as FunctionTypeAliasElementImpl;
|
| + FunctionTypeImpl type18 = element33.type as FunctionTypeImpl;
|
| + setTypeInformation(type18, node.returnType, element33.parameters);
|
| return null;
|
| }
|
| Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) {
|
| super.visitFunctionTypedFormalParameter(node);
|
| - ParameterElementImpl element33 = node.identifier.element as ParameterElementImpl;
|
| + ParameterElementImpl element34 = node.identifier.element as ParameterElementImpl;
|
| FunctionTypeImpl type = new FunctionTypeImpl.con1((null as ExecutableElement));
|
| setTypeInformation(type, node.returnType, getElements(node.parameters));
|
| - element33.type = type;
|
| + element34.type = type;
|
| return null;
|
| }
|
| Object visitMethodDeclaration(MethodDeclaration node) {
|
| super.visitMethodDeclaration(node);
|
| - ExecutableElementImpl element34 = node.element as ExecutableElementImpl;
|
| - FunctionTypeImpl type = new FunctionTypeImpl.con1(element34);
|
| - setTypeInformation(type, node.returnType, element34.parameters);
|
| - element34.type = type;
|
| - if (element34 is PropertyAccessorElementImpl) {
|
| - PropertyAccessorElementImpl accessor = element34 as PropertyAccessorElementImpl;
|
| + ExecutableElementImpl element35 = node.element as ExecutableElementImpl;
|
| + FunctionTypeImpl type = new FunctionTypeImpl.con1(element35);
|
| + setTypeInformation(type, node.returnType, element35.parameters);
|
| + element35.type = type;
|
| + if (element35 is PropertyAccessorElementImpl) {
|
| + PropertyAccessorElementImpl accessor = element35 as PropertyAccessorElementImpl;
|
| PropertyInducingElementImpl variable5 = accessor.variable as PropertyInducingElementImpl;
|
| if (accessor.isGetter()) {
|
| variable5.type = type.returnType;
|
| @@ -4164,9 +4198,9 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| } else {
|
| declaredType = getType4(typeName);
|
| }
|
| - Element element35 = node.identifier.element;
|
| - if (element35 is ParameterElement) {
|
| - ((element35 as ParameterElementImpl)).type = declaredType;
|
| + Element element36 = node.identifier.element;
|
| + if (element36 is ParameterElement) {
|
| + ((element36 as ParameterElementImpl)).type = declaredType;
|
| } else {
|
| }
|
| return null;
|
| @@ -4220,9 +4254,9 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| if (element is ClassElement) {
|
| setElement(typeName, element);
|
| type = ((element as ClassElement)).type;
|
| - } else if (element is TypeAliasElement) {
|
| + } else if (element is FunctionTypeAliasElement) {
|
| setElement(typeName, element);
|
| - type = ((element as TypeAliasElement)).type;
|
| + type = ((element as FunctionTypeAliasElement)).type;
|
| } else if (element is TypeVariableElement) {
|
| setElement(typeName, element);
|
| type = ((element as TypeVariableElement)).type;
|
| @@ -4235,14 +4269,14 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| return null;
|
| }
|
| if (argumentList != null) {
|
| - NodeList<TypeName> arguments5 = argumentList.arguments;
|
| - int argumentCount = arguments5.length;
|
| + NodeList<TypeName> arguments6 = argumentList.arguments;
|
| + int argumentCount = arguments6.length;
|
| List<Type2> parameters = getTypeArguments(type);
|
| int parameterCount = parameters.length;
|
| int count = Math.min(argumentCount, parameterCount);
|
| List<Type2> typeArguments = new List<Type2>();
|
| for (int i = 0; i < count; i++) {
|
| - Type2 argumentType = getType4(arguments5[i]);
|
| + Type2 argumentType = getType4(arguments6[i]);
|
| if (argumentType != null) {
|
| typeArguments.add(argumentType);
|
| }
|
| @@ -4289,11 +4323,11 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| } else {
|
| declaredType = getType4(typeName);
|
| }
|
| - Element element36 = node.name.element;
|
| - if (element36 is VariableElement) {
|
| - ((element36 as VariableElementImpl)).type = declaredType;
|
| - if (element36 is FieldElement) {
|
| - FieldElement field = element36 as FieldElement;
|
| + Element element37 = node.name.element;
|
| + if (element37 is VariableElement) {
|
| + ((element37 as VariableElementImpl)).type = declaredType;
|
| + if (element37 is FieldElement) {
|
| + FieldElement field = element37 as FieldElement;
|
| PropertyAccessorElementImpl getter5 = field.getter as PropertyAccessorElementImpl;
|
| FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter5);
|
| getterType.returnType = declaredType;
|
| @@ -4319,11 +4353,11 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| if (identifier == null) {
|
| return null;
|
| }
|
| - Element element37 = identifier.element;
|
| - if (element37 is! ClassElementImpl) {
|
| + Element element38 = identifier.element;
|
| + if (element38 is! ClassElementImpl) {
|
| return null;
|
| }
|
| - return element37 as ClassElementImpl;
|
| + return element38 as ClassElementImpl;
|
| }
|
| /**
|
| * Return an array containing all of the elements associated with the parameters in the given
|
| @@ -4334,9 +4368,9 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| List<ParameterElement> getElements(FormalParameterList parameterList) {
|
| List<ParameterElement> elements = new List<ParameterElement>();
|
| for (FormalParameter parameter in parameterList.parameters) {
|
| - ParameterElement element38 = parameter.identifier.element as ParameterElement;
|
| - if (element38 != null) {
|
| - elements.add(element38);
|
| + ParameterElement element39 = parameter.identifier.element as ParameterElement;
|
| + if (element39 != null) {
|
| + elements.add(element39);
|
| }
|
| }
|
| return new List.from(elements);
|
| @@ -4454,14 +4488,14 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| Identifier name16 = typeName.name;
|
| Element element = nameScope.lookup(name16, definingLibrary);
|
| if (element == null) {
|
| - reportError(undefinedError, name16, []);
|
| + reportError(undefinedError, name16, [name16.name]);
|
| } else if (element is ClassElement) {
|
| Type2 classType = ((element as ClassElement)).type;
|
| typeName.type = classType;
|
| if (classType is InterfaceType) {
|
| return classType as InterfaceType;
|
| }
|
| - reportError(nonInterfaceType, name16, []);
|
| + reportError(nonInterfaceType, name16, [name16.name]);
|
| } else if (element is MultiplyDefinedElement) {
|
| List<Element> elements = ((element as MultiplyDefinedElement)).conflictingElements;
|
| InterfaceType type = getType(elements);
|
| @@ -4469,7 +4503,7 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| typeName.type = type;
|
| }
|
| } else {
|
| - reportError(nonTypeError, name16, []);
|
| + reportError(nonTypeError, name16, [name16.name]);
|
| }
|
| return null;
|
| }
|
| @@ -4492,13 +4526,13 @@ class TypeResolverVisitor extends ScopedVisitor {
|
| }
|
| return new List.from(types);
|
| }
|
| - void setElement(Identifier typeName, Element element51) {
|
| - if (element51 != null) {
|
| + void setElement(Identifier typeName, Element element54) {
|
| + if (element54 != null) {
|
| if (typeName is SimpleIdentifier) {
|
| - ((typeName as SimpleIdentifier)).element = element51;
|
| + ((typeName as SimpleIdentifier)).element = element54;
|
| } else if (typeName is PrefixedIdentifier) {
|
| PrefixedIdentifier identifier = typeName as PrefixedIdentifier;
|
| - identifier.identifier.element = element51;
|
| + identifier.identifier.element = element54;
|
| SimpleIdentifier prefix9 = identifier.prefix;
|
| Element prefixElement = nameScope.lookup(prefix9, definingLibrary);
|
| if (prefixElement != null) {
|
| @@ -4658,14 +4692,14 @@ class FunctionTypeScope extends EnclosedScope {
|
| * @param enclosingScope the scope in which this scope is lexically enclosed
|
| * @param typeElement the element representing the type alias represented by this scope
|
| */
|
| - FunctionTypeScope(Scope enclosingScope, TypeAliasElement typeElement) : super(new EnclosedScope(enclosingScope)) {
|
| + FunctionTypeScope(Scope enclosingScope, FunctionTypeAliasElement typeElement) : super(new EnclosedScope(enclosingScope)) {
|
| defineTypeParameters(typeElement);
|
| }
|
| /**
|
| * Define the type parameters for the function type alias.
|
| * @param typeElement the element representing the type represented by this scope
|
| */
|
| - void defineTypeParameters(TypeAliasElement typeElement) {
|
| + void defineTypeParameters(FunctionTypeAliasElement typeElement) {
|
| Scope parameterScope = enclosingScope;
|
| for (TypeVariableElement parameter in typeElement.typeVariables) {
|
| parameterScope.define(parameter);
|
| @@ -4704,10 +4738,10 @@ class LabelScope {
|
| * @param onSwitchMember {@code true} if this label is associated with a {@code switch} member
|
| */
|
| LabelScope.con1(LabelScope outerScope, bool onSwitchStatement, bool onSwitchMember) {
|
| - _jtd_constructor_237_impl(outerScope, onSwitchStatement, onSwitchMember);
|
| + _jtd_constructor_248_impl(outerScope, onSwitchStatement, onSwitchMember);
|
| }
|
| - _jtd_constructor_237_impl(LabelScope outerScope, bool onSwitchStatement, bool onSwitchMember) {
|
| - _jtd_constructor_238_impl(outerScope, EMPTY_LABEL, new LabelElementImpl(_EMPTY_LABEL_IDENTIFIER, onSwitchStatement, onSwitchMember));
|
| + _jtd_constructor_248_impl(LabelScope outerScope, bool onSwitchStatement, bool onSwitchMember) {
|
| + _jtd_constructor_249_impl(outerScope, EMPTY_LABEL, new LabelElementImpl(_EMPTY_LABEL_IDENTIFIER, onSwitchStatement, onSwitchMember));
|
| }
|
| /**
|
| * Initialize a newly created scope to represent the given label.
|
| @@ -4716,9 +4750,9 @@ class LabelScope {
|
| * @param element the element to which the label resolves
|
| */
|
| LabelScope.con2(LabelScope outerScope2, String label4, LabelElement element19) {
|
| - _jtd_constructor_238_impl(outerScope2, label4, element19);
|
| + _jtd_constructor_249_impl(outerScope2, label4, element19);
|
| }
|
| - _jtd_constructor_238_impl(LabelScope outerScope2, String label4, LabelElement element19) {
|
| + _jtd_constructor_249_impl(LabelScope outerScope2, String label4, LabelElement element19) {
|
| this._outerScope = outerScope2;
|
| this._label = label4;
|
| this._element = element19;
|
| @@ -4848,7 +4882,7 @@ class LibraryScope extends EnclosedScope {
|
| for (FunctionElement element in compilationUnit.functions) {
|
| define(element);
|
| }
|
| - for (TypeAliasElement element in compilationUnit.typeAliases) {
|
| + for (FunctionTypeAliasElement element in compilationUnit.functionTypeAliases) {
|
| define(element);
|
| }
|
| for (ClassElement element in compilationUnit.types) {
|
| @@ -4994,7 +5028,7 @@ class NamespaceBuilder {
|
| for (FunctionElement element in compilationUnit.functions) {
|
| addIfPublic(definedNames, element);
|
| }
|
| - for (TypeAliasElement element in compilationUnit.typeAliases) {
|
| + for (FunctionTypeAliasElement element in compilationUnit.functionTypeAliases) {
|
| addIfPublic(definedNames, element);
|
| }
|
| for (ClassElement element in compilationUnit.types) {
|
| @@ -5233,16 +5267,11 @@ class ConstantVerifier extends RecursiveASTVisitor<Object> {
|
| */
|
| ErrorReporter _errorReporter;
|
| /**
|
| - * The constant evaluator used to evaluate constants.
|
| - */
|
| - ConstantEvaluator _evaluator;
|
| - /**
|
| * Initialize a newly created constant verifier.
|
| * @param errorReporter the error reporter by which errors will be reported
|
| */
|
| ConstantVerifier(ErrorReporter errorReporter) {
|
| this._errorReporter = errorReporter;
|
| - _evaluator = new ConstantEvaluator(errorReporter);
|
| }
|
| Object visitFunctionExpression(FunctionExpression node) {
|
| super.visitFunctionExpression(node);
|
| @@ -5264,14 +5293,14 @@ class ConstantVerifier extends RecursiveASTVisitor<Object> {
|
| Set<String> keys = new Set<String>();
|
| for (MapLiteralEntry entry in node.entries) {
|
| StringLiteral key4 = entry.key;
|
| - Object value = validate(key4, CompileTimeErrorCode.NON_CONSTANT_MAP_KEY);
|
| - if (value is String) {
|
| - if (keys.contains(value)) {
|
| + EvaluationResultImpl result = validate(key4, CompileTimeErrorCode.NON_CONSTANT_MAP_KEY);
|
| + if (result is ValidResult && ((result as ValidResult)).value is String) {
|
| + String value10 = ((result as ValidResult)).value as String;
|
| + if (keys.contains(value10)) {
|
| _errorReporter.reportError(StaticWarningCode.EQUAL_KEYS_IN_MAP, key4, []);
|
| } else {
|
| - javaSetAdd(keys, (value as String));
|
| + javaSetAdd(keys, value10);
|
| }
|
| - } else if (value != null) {
|
| }
|
| if (isConst) {
|
| validate(entry.value, CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE);
|
| @@ -5293,7 +5322,9 @@ class ConstantVerifier extends RecursiveASTVisitor<Object> {
|
| super.visitVariableDeclaration(node);
|
| Expression initializer4 = node.initializer;
|
| if (initializer4 != null && node.isConst()) {
|
| - validate(initializer4, CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE);
|
| + EvaluationResultImpl result = validate(initializer4, CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE);
|
| + VariableElementImpl element45 = node.element as VariableElementImpl;
|
| + element45.evaluationResult = result;
|
| }
|
| return null;
|
| }
|
| @@ -5304,21 +5335,18 @@ class ConstantVerifier extends RecursiveASTVisitor<Object> {
|
| * @param errorCode the error code to be used if the expression is not a compile time constant
|
| * @return the value of the compile time constant
|
| */
|
| - Object validate(Expression expression, ErrorCode errorCode) {
|
| - Object value = expression.accept(_evaluator);
|
| - if (identical(value, ConstantEvaluator.NOT_A_CONSTANT)) {
|
| - _errorReporter.reportError(errorCode, expression, []);
|
| - return null;
|
| - }
|
| - if (identical(value, errorCode)) {
|
| - _errorReporter.reportError(CompileTimeErrorCode.COMPILE_TIME_CONSTANT_RAISES_EXCEPTION, expression, []);
|
| - return null;
|
| - }
|
| - if (identical(value, errorCode)) {
|
| - _errorReporter.reportError(CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CONSTANT, expression, []);
|
| - return null;
|
| + EvaluationResultImpl validate(Expression expression, ErrorCode errorCode4) {
|
| + EvaluationResultImpl result = expression.accept(new ConstantVisitor());
|
| + if (result is ErrorResult) {
|
| + for (ErrorResult_ErrorData data in ((result as ErrorResult)).errorData) {
|
| + if (identical(data.errorCode, CompileTimeErrorCode.COMPILE_TIME_CONSTANT_RAISES_EXCEPTION_DIVIDE_BY_ZERO)) {
|
| + _errorReporter.reportError(data.errorCode, data.node, []);
|
| + } else {
|
| + _errorReporter.reportError(errorCode4, data.node, []);
|
| + }
|
| + }
|
| }
|
| - return value;
|
| + return result;
|
| }
|
| /**
|
| * Validate that the default value associated with each of the parameters in the given list is a
|
| @@ -5331,9 +5359,14 @@ class ConstantVerifier extends RecursiveASTVisitor<Object> {
|
| }
|
| for (FormalParameter parameter in parameters14.parameters) {
|
| if (parameter is DefaultFormalParameter) {
|
| - Expression defaultValue2 = ((parameter as DefaultFormalParameter)).defaultValue;
|
| + DefaultFormalParameter defaultParameter = parameter as DefaultFormalParameter;
|
| + Expression defaultValue2 = defaultParameter.defaultValue;
|
| if (defaultValue2 != null) {
|
| - validate(defaultValue2, CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE);
|
| + EvaluationResultImpl result = validate(defaultValue2, CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALUE);
|
| + if (defaultParameter.isConst()) {
|
| + VariableElementImpl element46 = parameter.element as VariableElementImpl;
|
| + element46.evaluationResult = result;
|
| + }
|
| }
|
| }
|
| }
|
| @@ -5447,10 +5480,9 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| Type2 type20 = typeName.type;
|
| if (type20 is InterfaceType) {
|
| InterfaceType interfaceType = type20 as InterfaceType;
|
| + checkForConstWithNonConst(node);
|
| checkForConstOrNewWithAbstractClass(node, typeName, interfaceType);
|
| checkForTypeArgumentNotMatchingBounds(node, constructorName4.element, typeName);
|
| - } else {
|
| - _errorReporter.reportError(CompileTimeErrorCode.NON_CONSTANT_MAP_KEY, typeName, []);
|
| }
|
| return super.visitInstanceCreationExpression(node);
|
| }
|
| @@ -5495,8 +5527,8 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| */
|
| bool checkForArgumentDefinitionTestNonParameter(ArgumentDefinitionTest node) {
|
| SimpleIdentifier identifier14 = node.identifier;
|
| - Element element44 = identifier14.element;
|
| - if (element44 != null && element44 is! ParameterElement) {
|
| + Element element47 = identifier14.element;
|
| + if (element47 != null && element47 is! ParameterElement) {
|
| _errorReporter.reportError(CompileTimeErrorCode.ARGUMENT_DEFINITION_TEST_NON_PARAMETER, identifier14, [identifier14.name]);
|
| return true;
|
| }
|
| @@ -5555,12 +5587,12 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| Expression expression16 = node.expression;
|
| Type2 type = expression16.staticType;
|
| if (type != null && type != _typeProvider.intType && type != _typeProvider.stringType) {
|
| - Element element45 = type.element;
|
| - if (element45 is ClassElement) {
|
| - ClassElement classElement = element45 as ClassElement;
|
| + Element element48 = type.element;
|
| + if (element48 is ClassElement) {
|
| + ClassElement classElement = element48 as ClassElement;
|
| MethodElement method = classElement.lookUpMethod("==", _currentLibrary);
|
| if (method != null && method.enclosingElement.type != _typeProvider.objectType) {
|
| - _errorReporter.reportError(CompileTimeErrorCode.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS, expression16, [element45.name]);
|
| + _errorReporter.reportError(CompileTimeErrorCode.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS, expression16, [element48.name]);
|
| return true;
|
| }
|
| }
|
| @@ -5606,7 +5638,7 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| ClassElement classElement = constructorElement.enclosingElement;
|
| List<FieldElement> elements = classElement.fields;
|
| for (FieldElement field in elements) {
|
| - if (!field.isFinal() && !field.isConst()) {
|
| + if (!field.isFinal() && !field.isConst() && !field.isSynthetic()) {
|
| _errorReporter.reportError(CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD, node, []);
|
| return true;
|
| }
|
| @@ -5639,8 +5671,8 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| */
|
| bool checkForConstOrNewWithAbstractClass(InstanceCreationExpression node, TypeName typeName, InterfaceType type) {
|
| if (type.element.isAbstract()) {
|
| - ConstructorElement element46 = node.element;
|
| - if (element46 != null && !element46.isFactory()) {
|
| + ConstructorElement element49 = node.element;
|
| + if (element49 != null && !element49.isFactory()) {
|
| if (identical(((node.keyword as sc.KeywordToken)).keyword, sc.Keyword.CONST)) {
|
| _errorReporter.reportError(StaticWarningCode.CONST_WITH_ABSTRACT_CLASS, typeName, []);
|
| } else {
|
| @@ -5652,6 +5684,20 @@ class ErrorVerifier extends RecursiveASTVisitor<Object> {
|
| return false;
|
| }
|
| /**
|
| + * This verifies that if the passed instance creation expression is 'const', then it is not being
|
| + * invoked on a constructor that is not 'const'.
|
| + * @param node the instance creation expression to evaluate
|
| + * @return return <code>true</code> if and only if an error code is generated on the passed node
|
| + * @see CompileTimeErrorCode#CONST_WITH_NON_CONST
|
| + */
|
| + bool checkForConstWithNonConst(InstanceCreationExpression node) {
|
| + if (node.isConst() && !node.element.isConst()) {
|
| + _errorReporter.reportError(CompileTimeErrorCode.CONST_WITH_NON_CONST, node, []);
|
| + return true;
|
| + }
|
| + return false;
|
| + }
|
| + /**
|
| * This verifies that the passed assignment expression represents a valid assignment.
|
| * @param node the assignment expression to evaluate
|
| * @return return <code>true</code> if and only if an error code is generated on the passed node
|
|
|