Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(337)

Side by Side Diff: pkg/analyzer_experimental/lib/src/generated/resolver.dart

Issue 12838003: Rename analyzer-experimental to analyzer_experimental. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // This code was auto-generated, is not intended to be edited, and is subject to 1 // This code was auto-generated, is not intended to be edited, and is subject to
2 // significant change. Please see the README file for more information. 2 // significant change. Please see the README file for more information.
3 3
4 library engine.resolver; 4 library engine.resolver;
5 5
6 import 'dart:collection'; 6 import 'dart:collection';
7 import 'java_core.dart'; 7 import 'java_core.dart';
8 import 'java_engine.dart'; 8 import 'java_engine.dart';
9 import 'source.dart'; 9 import 'source.dart';
10 import 'error.dart'; 10 import 'error.dart';
11 import 'scanner.dart' as sc; 11 import 'scanner.dart' as sc;
12 import 'utilities_dart.dart'; 12 import 'utilities_dart.dart';
13 import 'ast.dart'; 13 import 'ast.dart';
14 import 'parser.dart' show Parser; 14 import 'parser.dart' show Parser;
15 import 'element.dart' hide HideCombinator, ShowCombinator; 15 import 'element.dart' hide HideCombinator, ShowCombinator;
16 import 'html.dart' as ht; 16 import 'html.dart' as ht;
17 import 'engine.dart'; 17 import 'engine.dart';
18 import 'constant.dart';
18 import 'element.dart' as __imp_combi show HideCombinator, ShowCombinator; 19 import 'element.dart' as __imp_combi show HideCombinator, ShowCombinator;
19 20
20 /** 21 /**
21 * Instances of the class {@code CompilationUnitBuilder} build an element model for a single 22 * Instances of the class {@code CompilationUnitBuilder} build an element model for a single
22 * compilation unit. 23 * compilation unit.
23 * @coverage dart.engine.resolver 24 * @coverage dart.engine.resolver
24 */ 25 */
25 class CompilationUnitBuilder { 26 class CompilationUnitBuilder {
26 /** 27 /**
27 * The analysis context in which the element model will be built. 28 * The analysis context in which the element model will be built.
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 visitChildren(holder, node); 166 visitChildren(holder, node);
166 SimpleIdentifier constructorName = node.name; 167 SimpleIdentifier constructorName = node.name;
167 ConstructorElementImpl element = new ConstructorElementImpl(constructorName) ; 168 ConstructorElementImpl element = new ConstructorElementImpl(constructorName) ;
168 if (node.factoryKeyword != null) { 169 if (node.factoryKeyword != null) {
169 element.factory = true; 170 element.factory = true;
170 } 171 }
171 element.functions = holder.functions; 172 element.functions = holder.functions;
172 element.labels = holder.labels; 173 element.labels = holder.labels;
173 element.localVariables = holder.localVariables; 174 element.localVariables = holder.localVariables;
174 element.parameters = holder.parameters; 175 element.parameters = holder.parameters;
176 element.const2 = node.constKeyword != null;
175 _currentHolder.addConstructor(element); 177 _currentHolder.addConstructor(element);
176 node.element = element; 178 node.element = element;
177 if (constructorName != null) { 179 if (constructorName != null) {
178 constructorName.element = element; 180 constructorName.element = element;
179 } 181 }
180 return null; 182 return null;
181 } 183 }
182 Object visitDeclaredIdentifier(DeclaredIdentifier node) { 184 Object visitDeclaredIdentifier(DeclaredIdentifier node) {
183 SimpleIdentifier variableName = node.identifier; 185 SimpleIdentifier variableName = node.identifier;
184 sc.Token keyword27 = node.keyword; 186 sc.Token keyword27 = node.keyword;
185 LocalVariableElementImpl element = new LocalVariableElementImpl(variableName ); 187 LocalVariableElementImpl element = new LocalVariableElementImpl(variableName );
186 ForEachStatement statement = node.parent as ForEachStatement; 188 ForEachStatement statement = node.parent as ForEachStatement;
187 int declarationEnd = node.offset + node.length; 189 int declarationEnd = node.offset + node.length;
188 int statementEnd = statement.offset + statement.length; 190 int statementEnd = statement.offset + statement.length;
189 element.setVisibleRange(declarationEnd, statementEnd - declarationEnd - 1); 191 element.setVisibleRange(declarationEnd, statementEnd - declarationEnd - 1);
190 element.const2 = matches(keyword27, sc.Keyword.CONST); 192 element.const3 = matches(keyword27, sc.Keyword.CONST);
191 element.final2 = matches(keyword27, sc.Keyword.FINAL); 193 element.final2 = matches(keyword27, sc.Keyword.FINAL);
192 _currentHolder.addLocalVariable(element); 194 _currentHolder.addLocalVariable(element);
193 variableName.element = element; 195 variableName.element = element;
194 return super.visitDeclaredIdentifier(node); 196 return super.visitDeclaredIdentifier(node);
195 } 197 }
196 Object visitDefaultFormalParameter(DefaultFormalParameter node) { 198 Object visitDefaultFormalParameter(DefaultFormalParameter node) {
197 ElementHolder holder = new ElementHolder(); 199 ElementHolder holder = new ElementHolder();
198 visit(holder, node.defaultValue); 200 visit(holder, node.defaultValue);
199 FunctionElementImpl initializer = new FunctionElementImpl(); 201 FunctionElementImpl initializer = new FunctionElementImpl();
200 initializer.functions = holder.functions; 202 initializer.functions = holder.functions;
201 initializer.labels = holder.labels; 203 initializer.labels = holder.labels;
202 initializer.localVariables = holder.localVariables; 204 initializer.localVariables = holder.localVariables;
203 initializer.parameters = holder.parameters; 205 initializer.parameters = holder.parameters;
204 SimpleIdentifier parameterName = node.parameter.identifier; 206 SimpleIdentifier parameterName = node.parameter.identifier;
205 ParameterElementImpl parameter = new ParameterElementImpl(parameterName); 207 ParameterElementImpl parameter;
206 parameter.const2 = node.isConst(); 208 if (node.isConst()) {
209 parameter = new ConstParameterElementImpl(parameterName);
210 parameter.const3 = true;
211 } else {
212 parameter = new ParameterElementImpl(parameterName);
213 }
207 parameter.final2 = node.isFinal(); 214 parameter.final2 = node.isFinal();
208 parameter.initializer = initializer; 215 parameter.initializer = initializer;
209 parameter.parameterKind = node.kind; 216 parameter.parameterKind = node.kind;
210 FunctionBody body = getFunctionBody(node); 217 FunctionBody body = getFunctionBody(node);
211 if (body != null) { 218 if (body != null) {
212 parameter.setVisibleRange(body.offset, body.length); 219 parameter.setVisibleRange(body.offset, body.length);
213 } 220 }
214 _currentHolder.addParameter(parameter); 221 _currentHolder.addParameter(parameter);
215 parameterName.element = parameter; 222 parameterName.element = parameter;
216 node.parameter.accept(this); 223 node.parameter.accept(this);
217 return null; 224 return null;
218 } 225 }
219 Object visitFieldDeclaration(FieldDeclaration node) { 226 Object visitFieldDeclaration(FieldDeclaration node) {
220 bool wasInField = _inFieldContext; 227 bool wasInField = _inFieldContext;
221 _inFieldContext = true; 228 _inFieldContext = true;
222 try { 229 try {
223 node.visitChildren(this); 230 node.visitChildren(this);
224 } finally { 231 } finally {
225 _inFieldContext = wasInField; 232 _inFieldContext = wasInField;
226 } 233 }
227 return null; 234 return null;
228 } 235 }
229 Object visitFieldFormalParameter(FieldFormalParameter node) { 236 Object visitFieldFormalParameter(FieldFormalParameter node) {
230 if (node.parent is! DefaultFormalParameter) { 237 if (node.parent is! DefaultFormalParameter) {
231 SimpleIdentifier parameterName = node.identifier; 238 SimpleIdentifier parameterName = node.identifier;
232 ParameterElementImpl parameter = new ParameterElementImpl(parameterName); 239 ParameterElementImpl parameter = new ParameterElementImpl(parameterName);
233 parameter.const2 = node.isConst(); 240 parameter.const3 = node.isConst();
234 parameter.initializingFormal = true; 241 parameter.initializingFormal = true;
235 parameter.final2 = node.isFinal(); 242 parameter.final2 = node.isFinal();
236 parameter.parameterKind = node.kind; 243 parameter.parameterKind = node.kind;
237 _currentHolder.addParameter(parameter); 244 _currentHolder.addParameter(parameter);
238 parameterName.element = parameter; 245 parameterName.element = parameter;
239 } 246 }
240 return super.visitFieldFormalParameter(node); 247 return super.visitFieldFormalParameter(node);
241 } 248 }
242 Object visitFunctionDeclaration(FunctionDeclaration node) { 249 Object visitFunctionDeclaration(FunctionDeclaration node) {
243 FunctionExpression expression = node.functionExpression; 250 FunctionExpression expression = node.functionExpression;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 _currentHolder.addFunction(element); 337 _currentHolder.addFunction(element);
331 node.element = element; 338 node.element = element;
332 return null; 339 return null;
333 } 340 }
334 Object visitFunctionTypeAlias(FunctionTypeAlias node) { 341 Object visitFunctionTypeAlias(FunctionTypeAlias node) {
335 ElementHolder holder = new ElementHolder(); 342 ElementHolder holder = new ElementHolder();
336 visitChildren(holder, node); 343 visitChildren(holder, node);
337 SimpleIdentifier aliasName = node.name; 344 SimpleIdentifier aliasName = node.name;
338 List<ParameterElement> parameters10 = holder.parameters; 345 List<ParameterElement> parameters10 = holder.parameters;
339 List<TypeVariableElement> typeVariables6 = holder.typeVariables; 346 List<TypeVariableElement> typeVariables6 = holder.typeVariables;
340 TypeAliasElementImpl element = new TypeAliasElementImpl(aliasName); 347 FunctionTypeAliasElementImpl element = new FunctionTypeAliasElementImpl(alia sName);
341 element.parameters = parameters10; 348 element.parameters = parameters10;
342 element.typeVariables = typeVariables6; 349 element.typeVariables = typeVariables6;
343 FunctionTypeImpl type = new FunctionTypeImpl.con2(element); 350 FunctionTypeImpl type = new FunctionTypeImpl.con2(element);
344 type.typeArguments = createTypeVariableTypes(typeVariables6); 351 type.typeArguments = createTypeVariableTypes(typeVariables6);
345 element.type = type; 352 element.type = type;
346 _currentHolder.addTypeAlias(element); 353 _currentHolder.addTypeAlias(element);
347 aliasName.element = element; 354 aliasName.element = element;
348 return null; 355 return null;
349 } 356 }
350 Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { 357 Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 _currentHolder.addAccessor(setter); 434 _currentHolder.addAccessor(setter);
428 propertyNameNode.element = setter; 435 propertyNameNode.element = setter;
429 } 436 }
430 } 437 }
431 return null; 438 return null;
432 } 439 }
433 Object visitSimpleFormalParameter(SimpleFormalParameter node) { 440 Object visitSimpleFormalParameter(SimpleFormalParameter node) {
434 if (node.parent is! DefaultFormalParameter) { 441 if (node.parent is! DefaultFormalParameter) {
435 SimpleIdentifier parameterName = node.identifier; 442 SimpleIdentifier parameterName = node.identifier;
436 ParameterElementImpl parameter = new ParameterElementImpl(parameterName); 443 ParameterElementImpl parameter = new ParameterElementImpl(parameterName);
437 parameter.const2 = node.isConst(); 444 parameter.const3 = node.isConst();
438 parameter.final2 = node.isFinal(); 445 parameter.final2 = node.isFinal();
439 parameter.parameterKind = node.kind; 446 parameter.parameterKind = node.kind;
440 _currentHolder.addParameter(parameter); 447 _currentHolder.addParameter(parameter);
441 parameterName.element = parameter; 448 parameterName.element = parameter;
442 } 449 }
443 return super.visitSimpleFormalParameter(node); 450 return super.visitSimpleFormalParameter(node);
444 } 451 }
445 Object visitSuperExpression(SuperExpression node) { 452 Object visitSuperExpression(SuperExpression node) {
446 _isValidMixin = false; 453 _isValidMixin = false;
447 return super.visitSuperExpression(node); 454 return super.visitSuperExpression(node);
(...skipping 19 matching lines...) Expand all
467 Object visitTypeParameter(TypeParameter node) { 474 Object visitTypeParameter(TypeParameter node) {
468 SimpleIdentifier parameterName = node.name; 475 SimpleIdentifier parameterName = node.name;
469 TypeVariableElementImpl element = new TypeVariableElementImpl(parameterName) ; 476 TypeVariableElementImpl element = new TypeVariableElementImpl(parameterName) ;
470 TypeVariableTypeImpl type = new TypeVariableTypeImpl(element); 477 TypeVariableTypeImpl type = new TypeVariableTypeImpl(element);
471 element.type = type; 478 element.type = type;
472 _currentHolder.addTypeVariable(element); 479 _currentHolder.addTypeVariable(element);
473 parameterName.element = element; 480 parameterName.element = element;
474 return super.visitTypeParameter(node); 481 return super.visitTypeParameter(node);
475 } 482 }
476 Object visitVariableDeclaration(VariableDeclaration node) { 483 Object visitVariableDeclaration(VariableDeclaration node) {
484 sc.Token keyword28 = ((node.parent as VariableDeclarationList)).keyword;
485 bool isConst = matches(keyword28, sc.Keyword.CONST);
486 bool isFinal = matches(keyword28, sc.Keyword.FINAL);
487 bool hasInitializer = node.initializer != null;
477 VariableElementImpl element; 488 VariableElementImpl element;
478 if (_inFieldContext) { 489 if (_inFieldContext) {
479 SimpleIdentifier fieldName = node.name; 490 SimpleIdentifier fieldName = node.name;
480 FieldElementImpl field = new FieldElementImpl.con1(fieldName); 491 FieldElementImpl field;
492 if (isConst && hasInitializer) {
493 field = new ConstFieldElementImpl(fieldName);
494 } else {
495 field = new FieldElementImpl.con1(fieldName);
496 }
481 element = field; 497 element = field;
482 _currentHolder.addField(field); 498 _currentHolder.addField(field);
483 fieldName.element = field; 499 fieldName.element = field;
484 } else if (_inFunction) { 500 } else if (_inFunction) {
485 SimpleIdentifier variableName = node.name; 501 SimpleIdentifier variableName = node.name;
486 element = new LocalVariableElementImpl(variableName); 502 LocalVariableElementImpl variable;
503 if (isConst && hasInitializer) {
504 variable = new ConstLocalVariableElementImpl(variableName);
505 } else {
506 variable = new LocalVariableElementImpl(variableName);
507 }
508 element = variable;
487 Block enclosingBlock = node.getAncestor(Block); 509 Block enclosingBlock = node.getAncestor(Block);
488 int functionEnd = node.offset + node.length; 510 int functionEnd = node.offset + node.length;
489 int blockEnd = enclosingBlock.offset + enclosingBlock.length; 511 int blockEnd = enclosingBlock.offset + enclosingBlock.length;
490 ((element as LocalVariableElementImpl)).setVisibleRange(functionEnd, block End - functionEnd - 1); 512 variable.setVisibleRange(functionEnd, blockEnd - functionEnd - 1);
491 _currentHolder.addLocalVariable((element as LocalVariableElementImpl)); 513 _currentHolder.addLocalVariable(variable);
492 variableName.element = element; 514 variableName.element = element;
493 } else { 515 } else {
494 SimpleIdentifier variableName = node.name; 516 SimpleIdentifier variableName = node.name;
495 element = new TopLevelVariableElementImpl.con1(variableName); 517 TopLevelVariableElementImpl variable;
496 _currentHolder.addTopLevelVariable((element as TopLevelVariableElementImpl )); 518 if (isConst && hasInitializer) {
519 variable = new ConstTopLevelVariableElementImpl(variableName);
520 } else {
521 variable = new TopLevelVariableElementImpl.con1(variableName);
522 }
523 element = variable;
524 _currentHolder.addTopLevelVariable(variable);
497 variableName.element = element; 525 variableName.element = element;
498 } 526 }
499 sc.Token keyword28 = ((node.parent as VariableDeclarationList)).keyword; 527 element.const3 = isConst;
500 bool isFinal = matches(keyword28, sc.Keyword.FINAL);
501 element.const2 = matches(keyword28, sc.Keyword.CONST);
502 element.final2 = isFinal; 528 element.final2 = isFinal;
503 if (node.initializer != null) { 529 if (hasInitializer) {
504 ElementHolder holder = new ElementHolder(); 530 ElementHolder holder = new ElementHolder();
505 bool wasInFieldContext = _inFieldContext; 531 bool wasInFieldContext = _inFieldContext;
506 _inFieldContext = false; 532 _inFieldContext = false;
507 try { 533 try {
508 visit(holder, node.initializer); 534 visit(holder, node.initializer);
509 } finally { 535 } finally {
510 _inFieldContext = wasInFieldContext; 536 _inFieldContext = wasInFieldContext;
511 } 537 }
512 FunctionElementImpl initializer = new FunctionElementImpl(); 538 FunctionElementImpl initializer = new FunctionElementImpl();
513 initializer.functions = holder.functions; 539 initializer.functions = holder.functions;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 * @coverage dart.engine.resolver 635 * @coverage dart.engine.resolver
610 */ 636 */
611 class ElementHolder { 637 class ElementHolder {
612 List<PropertyAccessorElement> _accessors = new List<PropertyAccessorElement>() ; 638 List<PropertyAccessorElement> _accessors = new List<PropertyAccessorElement>() ;
613 List<ConstructorElement> _constructors = new List<ConstructorElement>(); 639 List<ConstructorElement> _constructors = new List<ConstructorElement>();
614 List<FieldElement> _fields = new List<FieldElement>(); 640 List<FieldElement> _fields = new List<FieldElement>();
615 List<FunctionElement> _functions = new List<FunctionElement>(); 641 List<FunctionElement> _functions = new List<FunctionElement>();
616 List<LabelElement> _labels = new List<LabelElement>(); 642 List<LabelElement> _labels = new List<LabelElement>();
617 List<VariableElement> _localVariables = new List<VariableElement>(); 643 List<VariableElement> _localVariables = new List<VariableElement>();
618 List<MethodElement> _methods = new List<MethodElement>(); 644 List<MethodElement> _methods = new List<MethodElement>();
619 List<TypeAliasElement> _typeAliases = new List<TypeAliasElement>(); 645 List<FunctionTypeAliasElement> _typeAliases = new List<FunctionTypeAliasElemen t>();
620 List<ParameterElement> _parameters = new List<ParameterElement>(); 646 List<ParameterElement> _parameters = new List<ParameterElement>();
621 List<VariableElement> _topLevelVariables = new List<VariableElement>(); 647 List<VariableElement> _topLevelVariables = new List<VariableElement>();
622 List<ClassElement> _types = new List<ClassElement>(); 648 List<ClassElement> _types = new List<ClassElement>();
623 List<TypeVariableElement> _typeVariables = new List<TypeVariableElement>(); 649 List<TypeVariableElement> _typeVariables = new List<TypeVariableElement>();
624 /** 650 /**
625 * Initialize a newly created element holder. 651 * Initialize a newly created element holder.
626 */ 652 */
627 ElementHolder() : super() { 653 ElementHolder() : super() {
628 } 654 }
629 void addAccessor(PropertyAccessorElement element) { 655 void addAccessor(PropertyAccessorElement element) {
(...skipping 19 matching lines...) Expand all
649 } 675 }
650 void addParameter(ParameterElement element) { 676 void addParameter(ParameterElement element) {
651 _parameters.add(element); 677 _parameters.add(element);
652 } 678 }
653 void addTopLevelVariable(TopLevelVariableElement element) { 679 void addTopLevelVariable(TopLevelVariableElement element) {
654 _topLevelVariables.add(element); 680 _topLevelVariables.add(element);
655 } 681 }
656 void addType(ClassElement element) { 682 void addType(ClassElement element) {
657 _types.add(element); 683 _types.add(element);
658 } 684 }
659 void addTypeAlias(TypeAliasElement element) { 685 void addTypeAlias(FunctionTypeAliasElement element) {
660 _typeAliases.add(element); 686 _typeAliases.add(element);
661 } 687 }
662 void addTypeVariable(TypeVariableElement element) { 688 void addTypeVariable(TypeVariableElement element) {
663 _typeVariables.add(element); 689 _typeVariables.add(element);
664 } 690 }
665 List<PropertyAccessorElement> get accessors => new List.from(_accessors); 691 List<PropertyAccessorElement> get accessors => new List.from(_accessors);
666 List<ConstructorElement> get constructors => new List.from(_constructors); 692 List<ConstructorElement> get constructors => new List.from(_constructors);
667 FieldElement getField(String fieldName) { 693 FieldElement getField(String fieldName) {
668 for (FieldElement field in _fields) { 694 for (FieldElement field in _fields) {
669 if (field.name == fieldName) { 695 if (field.name == fieldName) {
670 return field; 696 return field;
671 } 697 }
672 } 698 }
673 return null; 699 return null;
674 } 700 }
675 List<FieldElement> get fields => new List.from(_fields); 701 List<FieldElement> get fields => new List.from(_fields);
676 List<FunctionElement> get functions => new List.from(_functions); 702 List<FunctionElement> get functions => new List.from(_functions);
677 List<LabelElement> get labels => new List.from(_labels); 703 List<LabelElement> get labels => new List.from(_labels);
678 List<LocalVariableElement> get localVariables => new List.from(_localVariables ); 704 List<LocalVariableElement> get localVariables => new List.from(_localVariables );
679 List<MethodElement> get methods => new List.from(_methods); 705 List<MethodElement> get methods => new List.from(_methods);
680 List<ParameterElement> get parameters => new List.from(_parameters); 706 List<ParameterElement> get parameters => new List.from(_parameters);
681 List<TopLevelVariableElement> get topLevelVariables => new List.from(_topLevel Variables); 707 List<TopLevelVariableElement> get topLevelVariables => new List.from(_topLevel Variables);
682 List<TypeAliasElement> get typeAliases => new List.from(_typeAliases); 708 List<FunctionTypeAliasElement> get typeAliases => new List.from(_typeAliases);
683 List<ClassElement> get types => new List.from(_types); 709 List<ClassElement> get types => new List.from(_types);
684 List<TypeVariableElement> get typeVariables => new List.from(_typeVariables); 710 List<TypeVariableElement> get typeVariables => new List.from(_typeVariables);
685 } 711 }
686 /** 712 /**
687 * Instances of the class {@code HtmlUnitBuilder} build an element model for a s ingle HTML unit. 713 * Instances of the class {@code HtmlUnitBuilder} build an element model for a s ingle HTML unit.
688 */ 714 */
689 class HtmlUnitBuilder implements ht.XmlVisitor<Object> { 715 class HtmlUnitBuilder implements ht.XmlVisitor<Object> {
690 static String _APPLICATION_DART_IN_DOUBLE_QUOTES = "\"application/dart\""; 716 static String _APPLICATION_DART_IN_DOUBLE_QUOTES = "\"application/dart\"";
691 static String _APPLICATION_DART_IN_SINGLE_QUOTES = "'application/dart'"; 717 static String _APPLICATION_DART_IN_SINGLE_QUOTES = "'application/dart'";
692 static String _SCRIPT = "script"; 718 static String _SCRIPT = "script";
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 */ 901 */
876 ElementResolver(ResolverVisitor resolver) { 902 ElementResolver(ResolverVisitor resolver) {
877 this._resolver = resolver; 903 this._resolver = resolver;
878 } 904 }
879 Object visitAssignmentExpression(AssignmentExpression node) { 905 Object visitAssignmentExpression(AssignmentExpression node) {
880 sc.TokenType operator7 = node.operator.type; 906 sc.TokenType operator7 = node.operator.type;
881 if (operator7 != sc.TokenType.EQ) { 907 if (operator7 != sc.TokenType.EQ) {
882 operator7 = operatorFromCompoundAssignment(operator7); 908 operator7 = operatorFromCompoundAssignment(operator7);
883 Expression leftNode = node.leftHandSide; 909 Expression leftNode = node.leftHandSide;
884 if (leftNode != null) { 910 if (leftNode != null) {
885 Type2 leftType = leftNode.staticType; 911 Type2 leftType = getType(leftNode);
886 if (leftType != null) { 912 if (leftType != null) {
887 Element leftElement = leftType.element; 913 Element leftElement = leftType.element;
888 if (leftElement != null) { 914 if (leftElement != null) {
889 MethodElement method = lookUpMethod(leftElement, operator7.lexeme); 915 MethodElement method = lookUpMethod(leftElement, operator7.lexeme);
890 if (method != null) { 916 if (method != null) {
891 node.element = method; 917 node.element = method;
892 } else { 918 } else {
893 } 919 }
894 } 920 }
895 } 921 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 } 981 }
956 Object visitContinueStatement(ContinueStatement node) { 982 Object visitContinueStatement(ContinueStatement node) {
957 SimpleIdentifier labelNode = node.label; 983 SimpleIdentifier labelNode = node.label;
958 LabelElementImpl labelElement = lookupLabel(node, labelNode); 984 LabelElementImpl labelElement = lookupLabel(node, labelNode);
959 if (labelElement != null && labelElement.isOnSwitchStatement()) { 985 if (labelElement != null && labelElement.isOnSwitchStatement()) {
960 _resolver.reportError(ResolverErrorCode.CONTINUE_LABEL_ON_SWITCH, labelNod e, []); 986 _resolver.reportError(ResolverErrorCode.CONTINUE_LABEL_ON_SWITCH, labelNod e, []);
961 } 987 }
962 return null; 988 return null;
963 } 989 }
964 Object visitExportDirective(ExportDirective node) { 990 Object visitExportDirective(ExportDirective node) {
965 Element element21 = node.element; 991 Element element22 = node.element;
966 if (element21 is ExportElement) { 992 if (element22 is ExportElement) {
967 resolveCombinators(((element21 as ExportElement)).exportedLibrary, node.co mbinators); 993 resolveCombinators(((element22 as ExportElement)).exportedLibrary, node.co mbinators);
968 } 994 }
969 return null; 995 return null;
970 } 996 }
971 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) => null; 997 Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) => null;
972 Object visitImportDirective(ImportDirective node) { 998 Object visitImportDirective(ImportDirective node) {
973 SimpleIdentifier prefixNode = node.prefix; 999 SimpleIdentifier prefixNode = node.prefix;
974 if (prefixNode != null) { 1000 if (prefixNode != null) {
975 String prefixName = prefixNode.name; 1001 String prefixName = prefixNode.name;
976 for (PrefixElement prefixElement in _resolver.definingLibrary.prefixes) { 1002 for (PrefixElement prefixElement in _resolver.definingLibrary.prefixes) {
977 if (prefixElement.name == prefixName) { 1003 if (prefixElement.name == prefixName) {
978 recordResolution(prefixNode, prefixElement); 1004 recordResolution(prefixNode, prefixElement);
979 break; 1005 break;
980 } 1006 }
981 } 1007 }
982 } 1008 }
983 Element element22 = node.element; 1009 Element element23 = node.element;
984 if (element22 is ImportElement) { 1010 if (element23 is ImportElement) {
985 resolveCombinators(((element22 as ImportElement)).importedLibrary, node.co mbinators); 1011 resolveCombinators(((element23 as ImportElement)).importedLibrary, node.co mbinators);
986 } 1012 }
987 return null; 1013 return null;
988 } 1014 }
989 Object visitIndexExpression(IndexExpression node) { 1015 Object visitIndexExpression(IndexExpression node) {
990 Type2 arrayType = getType(node.realTarget); 1016 Type2 arrayType = getType(node.realTarget);
991 if (arrayType == null || arrayType.isDynamic()) { 1017 if (arrayType == null || arrayType.isDynamic()) {
992 return null; 1018 return null;
993 } 1019 }
994 Element arrayTypeElement = arrayType.element; 1020 Element arrayTypeElement = arrayType.element;
995 String operator; 1021 String operator;
(...skipping 23 matching lines...) Expand all
1019 if (target == null) { 1045 if (target == null) {
1020 element = _resolver.nameScope.lookup(methodName2, _resolver.definingLibrar y); 1046 element = _resolver.nameScope.lookup(methodName2, _resolver.definingLibrar y);
1021 if (element == null) { 1047 if (element == null) {
1022 element = lookUpMethod(_resolver.enclosingClass, methodName2.name); 1048 element = lookUpMethod(_resolver.enclosingClass, methodName2.name);
1023 if (element == null) { 1049 if (element == null) {
1024 PropertyAccessorElement getter = lookUpGetter(_resolver.enclosingClass , methodName2.name); 1050 PropertyAccessorElement getter = lookUpGetter(_resolver.enclosingClass , methodName2.name);
1025 if (getter != null) { 1051 if (getter != null) {
1026 FunctionType getterType = getter.type; 1052 FunctionType getterType = getter.type;
1027 if (getterType != null) { 1053 if (getterType != null) {
1028 Type2 returnType4 = getterType.returnType; 1054 Type2 returnType4 = getterType.returnType;
1029 if (!returnType4.isDynamic() && returnType4 is! FunctionType && !r eturnType4.isDartCoreFunction()) { 1055 if (!isExecutableType(returnType4)) {
1030 _resolver.reportError(StaticTypeWarningCode.INVOCATION_OF_NON_FU NCTION, methodName2, [methodName2.name]); 1056 _resolver.reportError(StaticTypeWarningCode.INVOCATION_OF_NON_FU NCTION, methodName2, [methodName2.name]);
1031 } 1057 }
1032 } 1058 }
1033 recordResolution(methodName2, getter); 1059 recordResolution(methodName2, getter);
1034 return null; 1060 return null;
1035 } 1061 }
1036 } 1062 }
1037 } 1063 }
1038 } else { 1064 } else {
1039 Type2 targetType = getType(target); 1065 Type2 targetType = getType(target);
1040 if (targetType is InterfaceType) { 1066 if (targetType is InterfaceType) {
1041 element = lookUpMethod(targetType.element, methodName2.name); 1067 element = lookUpMethod(targetType.element, methodName2.name);
1042 if (element == null) { 1068 if (element == null) {
1043 PropertyAccessorElement accessor = lookUpGetterInType((targetType.elem ent as ClassElement), methodName2.name); 1069 ClassElement targetClass = targetType.element as ClassElement;
1070 PropertyAccessorElement accessor = lookUpGetterInType(targetClass, met hodName2.name);
1044 if (accessor != null) { 1071 if (accessor != null) {
1045 Type2 returnType5 = accessor.type.returnType; 1072 Type2 returnType5 = accessor.type.returnType.substitute2(((targetTyp e as InterfaceType)).typeArguments, TypeVariableTypeImpl.getTypes(targetClass.ty peVariables));
1046 if (!returnType5.isDynamic() && returnType5 is! FunctionType && !ret urnType5.isDartCoreFunction()) { 1073 if (!isExecutableType(returnType5)) {
1047 _resolver.reportError(StaticTypeWarningCode.INVOCATION_OF_NON_FUNC TION, methodName2, [methodName2.name]); 1074 _resolver.reportError(StaticTypeWarningCode.INVOCATION_OF_NON_FUNC TION, methodName2, [methodName2.name]);
1048 return null; 1075 return null;
1049 } 1076 }
1050 element = accessor; 1077 element = accessor;
1051 } 1078 }
1052 } 1079 }
1053 if (element == null && target is SuperExpression) { 1080 if (element == null && target is SuperExpression) {
1054 _resolver.reportError(StaticTypeWarningCode.UNDEFINED_SUPER_METHOD, me thodName2, [methodName2.name, targetType.element.name]); 1081 _resolver.reportError(StaticTypeWarningCode.UNDEFINED_SUPER_METHOD, me thodName2, [methodName2.name, targetType.element.name]);
1055 return null; 1082 return null;
1056 } 1083 }
(...skipping 12 matching lines...) Expand all
1069 } 1096 }
1070 ExecutableElement invokedMethod = null; 1097 ExecutableElement invokedMethod = null;
1071 if (element is ExecutableElement) { 1098 if (element is ExecutableElement) {
1072 invokedMethod = element as ExecutableElement; 1099 invokedMethod = element as ExecutableElement;
1073 } else { 1100 } else {
1074 if (element is PropertyInducingElement) { 1101 if (element is PropertyInducingElement) {
1075 PropertyAccessorElement getter3 = ((element as PropertyInducingElement)) .getter; 1102 PropertyAccessorElement getter3 = ((element as PropertyInducingElement)) .getter;
1076 FunctionType getterType = getter3.type; 1103 FunctionType getterType = getter3.type;
1077 if (getterType != null) { 1104 if (getterType != null) {
1078 Type2 returnType6 = getterType.returnType; 1105 Type2 returnType6 = getterType.returnType;
1079 if (!returnType6.isDynamic() && returnType6 is! FunctionType && !retur nType6.isDartCoreFunction()) { 1106 if (!isExecutableType(returnType6)) {
1080 _resolver.reportError(StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTI ON, methodName2, [methodName2.name]); 1107 _resolver.reportError(StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTI ON, methodName2, [methodName2.name]);
1081 } 1108 }
1082 } 1109 }
1083 recordResolution(methodName2, element); 1110 recordResolution(methodName2, element);
1084 return null; 1111 return null;
1085 } else if (element is VariableElement) { 1112 } else if (element is VariableElement) {
1086 Type2 variableType = ((element as VariableElement)).type; 1113 Type2 variableType = ((element as VariableElement)).type;
1087 if (!variableType.isDynamic() && variableType is! FunctionType && !varia bleType.isDartCoreFunction()) { 1114 if (!isExecutableType(variableType)) {
1088 _resolver.reportError(StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION , methodName2, [methodName2.name]); 1115 _resolver.reportError(StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION , methodName2, [methodName2.name]);
1089 } 1116 }
1090 recordResolution(methodName2, element); 1117 recordResolution(methodName2, element);
1091 return null; 1118 return null;
1092 } else { 1119 } else {
1093 _resolver.reportError(StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION, methodName2, [methodName2.name]); 1120 _resolver.reportError(StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION, methodName2, [methodName2.name]);
1094 return null; 1121 return null;
1095 } 1122 }
1096 } 1123 }
1097 recordResolution(methodName2, invokedMethod); 1124 recordResolution(methodName2, invokedMethod);
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
1376 * @param expression the expression whose type is to be returned 1403 * @param expression the expression whose type is to be returned
1377 * @return the type of the given expression 1404 * @return the type of the given expression
1378 */ 1405 */
1379 Type2 getType(Expression expression) { 1406 Type2 getType(Expression expression) {
1380 if (expression is NullLiteral) { 1407 if (expression is NullLiteral) {
1381 return _resolver.typeProvider.objectType; 1408 return _resolver.typeProvider.objectType;
1382 } 1409 }
1383 return expression.staticType; 1410 return expression.staticType;
1384 } 1411 }
1385 /** 1412 /**
1413 * Return {@code true} if the given type represents an object that could be in voked using the call
1414 * operator '()'.
1415 * @param type the type being tested
1416 * @return {@code true} if the given type represents an object that could be i nvoked
1417 */
1418 bool isExecutableType(Type2 type) => type.isDynamic() || (type is FunctionType ) || type.isDartCoreFunction();
1419 /**
1386 * Look up the getter with the given name in the given type. Return the elemen t representing the 1420 * Look up the getter with the given name in the given type. Return the elemen t representing the
1387 * getter that was found, or {@code null} if there is no getter with the given name. 1421 * getter that was found, or {@code null} if there is no getter with the given name.
1388 * @param element the element representing the type in which the getter is def ined 1422 * @param element the element representing the type in which the getter is def ined
1389 * @param getterName the name of the getter being looked up 1423 * @param getterName the name of the getter being looked up
1390 * @return the element representing the getter that was found 1424 * @return the element representing the getter that was found
1391 */ 1425 */
1392 PropertyAccessorElement lookUpGetter(Element element, String getterName) { 1426 PropertyAccessorElement lookUpGetter(Element element, String getterName) {
1393 if (identical(element, DynamicTypeImpl.instance)) { 1427 if (identical(element, DynamicTypeImpl.instance)) {
1394 return null; 1428 return null;
1395 } 1429 }
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
1657 break; 1691 break;
1658 } 1692 }
1659 AnalysisEngine.instance.logger.logError("Failed to map ${operator.lexeme} to it's corresponding operator"); 1693 AnalysisEngine.instance.logger.logError("Failed to map ${operator.lexeme} to it's corresponding operator");
1660 return operator; 1694 return operator;
1661 } 1695 }
1662 /** 1696 /**
1663 * Record the fact that the given AST node was resolved to the given element. 1697 * Record the fact that the given AST node was resolved to the given element.
1664 * @param node the AST node that was resolved 1698 * @param node the AST node that was resolved
1665 * @param element the element to which the AST node was resolved 1699 * @param element the element to which the AST node was resolved
1666 */ 1700 */
1667 void recordResolution(SimpleIdentifier node, Element element49) { 1701 void recordResolution(SimpleIdentifier node, Element element52) {
1668 if (element49 != null) { 1702 if (element52 != null) {
1669 node.element = element49; 1703 node.element = element52;
1670 } 1704 }
1671 } 1705 }
1672 /** 1706 /**
1673 * Report the {@link StaticTypeWarningCode}s <code>UNDEFINED_SETTER</code> and 1707 * Report the {@link StaticTypeWarningCode}s <code>UNDEFINED_SETTER</code> and
1674 * <code>UNDEFINED_GETTER</code>. 1708 * <code>UNDEFINED_GETTER</code>.
1675 * @param node the prefixed identifier that gives the context to determine if the error on the 1709 * @param node the prefixed identifier that gives the context to determine if the error on the
1676 * undefined identifier is a getter or a setter 1710 * undefined identifier is a getter or a setter
1677 * @param identifier the identifier in the passed prefix identifier 1711 * @param identifier the identifier in the passed prefix identifier
1678 * @param typeName the name of the type of the left hand side of the passed pr efixed identifier 1712 * @param typeName the name of the type of the left hand side of the passed pr efixed identifier
1679 */ 1713 */
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1729 } 1763 }
1730 } 1764 }
1731 } 1765 }
1732 /** 1766 /**
1733 * If the given element is a type variable, resolve it to the class that shoul d be used when 1767 * If the given element is a type variable, resolve it to the class that shoul d be used when
1734 * looking up members. Otherwise, return the original element. 1768 * looking up members. Otherwise, return the original element.
1735 * @param element the element that is to be resolved if it is a type variable 1769 * @param element the element that is to be resolved if it is a type variable
1736 * @return the class that should be used in place of the argument if it is a t ype variable, or the 1770 * @return the class that should be used in place of the argument if it is a t ype variable, or the
1737 * original argument if it isn't a type variable 1771 * original argument if it isn't a type variable
1738 */ 1772 */
1739 Element resolveTypeVariable(Element element50) { 1773 Element resolveTypeVariable(Element element53) {
1740 if (element50 is TypeVariableElement) { 1774 if (element53 is TypeVariableElement) {
1741 Type2 bound4 = ((element50 as TypeVariableElement)).bound; 1775 Type2 bound4 = ((element53 as TypeVariableElement)).bound;
1742 if (bound4 == null) { 1776 if (bound4 == null) {
1743 return _resolver.typeProvider.objectType.element; 1777 return _resolver.typeProvider.objectType.element;
1744 } 1778 }
1745 return bound4.element; 1779 return bound4.element;
1746 } 1780 }
1747 return element50; 1781 return element53;
1748 } 1782 }
1749 } 1783 }
1750 class Identifier_4 extends Identifier { 1784 class Identifier_4 extends Identifier {
1751 String name9; 1785 String name9;
1752 Identifier_4(this.name9) : super(); 1786 Identifier_4(this.name9) : super();
1753 accept(ASTVisitor visitor) => null; 1787 accept(ASTVisitor visitor) => null;
1754 sc.Token get beginToken => null; 1788 sc.Token get beginToken => null;
1755 Element get element => null; 1789 Element get element => null;
1756 sc.Token get endToken => null; 1790 sc.Token get endToken => null;
1757 String get name => name9; 1791 String get name => name9;
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
2165 Map<Source, Library> _libraryMap = new Map<Source, Library>(); 2199 Map<Source, Library> _libraryMap = new Map<Source, Library>();
2166 /** 2200 /**
2167 * A collection containing the libraries that are being resolved together. 2201 * A collection containing the libraries that are being resolved together.
2168 */ 2202 */
2169 Set<Library> _librariesInCycles; 2203 Set<Library> _librariesInCycles;
2170 /** 2204 /**
2171 * Initialize a newly created library resolver to resolve libraries within the given context. 2205 * Initialize a newly created library resolver to resolve libraries within the given context.
2172 * @param analysisContext the analysis context in which the library is being a nalyzed 2206 * @param analysisContext the analysis context in which the library is being a nalyzed
2173 */ 2207 */
2174 LibraryResolver.con1(AnalysisContextImpl analysisContext) { 2208 LibraryResolver.con1(AnalysisContextImpl analysisContext) {
2175 _jtd_constructor_226_impl(analysisContext); 2209 _jtd_constructor_237_impl(analysisContext);
2176 } 2210 }
2177 _jtd_constructor_226_impl(AnalysisContextImpl analysisContext) { 2211 _jtd_constructor_237_impl(AnalysisContextImpl analysisContext) {
2178 _jtd_constructor_227_impl(analysisContext, null); 2212 _jtd_constructor_238_impl(analysisContext, null);
2179 } 2213 }
2180 /** 2214 /**
2181 * Initialize a newly created library resolver to resolve libraries within the given context. 2215 * Initialize a newly created library resolver to resolve libraries within the given context.
2182 * @param analysisContext the analysis context in which the library is being a nalyzed 2216 * @param analysisContext the analysis context in which the library is being a nalyzed
2183 * @param errorListener the listener to which analysis errors will be reported 2217 * @param errorListener the listener to which analysis errors will be reported
2184 */ 2218 */
2185 LibraryResolver.con2(AnalysisContextImpl analysisContext2, AnalysisErrorListen er additionalAnalysisErrorListener) { 2219 LibraryResolver.con2(AnalysisContextImpl analysisContext2, AnalysisErrorListen er additionalAnalysisErrorListener) {
2186 _jtd_constructor_227_impl(analysisContext2, additionalAnalysisErrorListener) ; 2220 _jtd_constructor_238_impl(analysisContext2, additionalAnalysisErrorListener) ;
2187 } 2221 }
2188 _jtd_constructor_227_impl(AnalysisContextImpl analysisContext2, AnalysisErrorL istener additionalAnalysisErrorListener) { 2222 _jtd_constructor_238_impl(AnalysisContextImpl analysisContext2, AnalysisErrorL istener additionalAnalysisErrorListener) {
2189 this._analysisContext = analysisContext2; 2223 this._analysisContext = analysisContext2;
2190 this._recordingErrorListener = new RecordingErrorListener(); 2224 this._recordingErrorListener = new RecordingErrorListener();
2191 if (additionalAnalysisErrorListener == null) { 2225 if (additionalAnalysisErrorListener == null) {
2192 this._errorListener = _recordingErrorListener; 2226 this._errorListener = _recordingErrorListener;
2193 } else { 2227 } else {
2194 this._errorListener = new AnalysisErrorListener_5(this, additionalAnalysis ErrorListener); 2228 this._errorListener = new AnalysisErrorListener_5(this, additionalAnalysis ErrorListener);
2195 } 2229 }
2196 _coreLibrarySource = analysisContext2.sourceFactory.forUri(LibraryElementBui lder.CORE_LIBRARY_URI); 2230 _coreLibrarySource = analysisContext2.sourceFactory.forUri(LibraryElementBui lder.CORE_LIBRARY_URI);
2197 } 2231 }
2198 /** 2232 /**
(...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after
2982 } 3016 }
2983 try { 3017 try {
2984 super.visitSwitchStatement(node); 3018 super.visitSwitchStatement(node);
2985 } finally { 3019 } finally {
2986 _labelScope = outerScope; 3020 _labelScope = outerScope;
2987 } 3021 }
2988 return null; 3022 return null;
2989 } 3023 }
2990 Object visitVariableDeclaration(VariableDeclaration node) { 3024 Object visitVariableDeclaration(VariableDeclaration node) {
2991 if (node.parent.parent is! TopLevelVariableDeclaration && node.parent.parent is! FieldDeclaration) { 3025 if (node.parent.parent is! TopLevelVariableDeclaration && node.parent.parent is! FieldDeclaration) {
2992 VariableElement element23 = node.element; 3026 VariableElement element24 = node.element;
2993 if (element23 != null) { 3027 if (element24 != null) {
2994 _nameScope.define(element23); 3028 _nameScope.define(element24);
2995 } 3029 }
2996 } 3030 }
2997 super.visitVariableDeclaration(node); 3031 super.visitVariableDeclaration(node);
2998 return null; 3032 return null;
2999 } 3033 }
3000 Object visitWhileStatement(WhileStatement node) { 3034 Object visitWhileStatement(WhileStatement node) {
3001 LabelScope outerScope = _labelScope; 3035 LabelScope outerScope = _labelScope;
3002 _labelScope = new LabelScope.con1(outerScope, false, false); 3036 _labelScope = new LabelScope.con1(outerScope, false, false);
3003 try { 3037 try {
3004 super.visitWhileStatement(node); 3038 super.visitWhileStatement(node);
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
3325 /** 3359 /**
3326 * The Dart Language Specification, 12.6: <blockquote>The static type of a lis t literal of the 3360 * The Dart Language Specification, 12.6: <blockquote>The static type of a lis t literal of the
3327 * form <i><b>const</b> &lt;E&gt;[e<sub>1</sub>, &hellip;, e<sub>n</sub>]</i> or the form 3361 * form <i><b>const</b> &lt;E&gt;[e<sub>1</sub>, &hellip;, e<sub>n</sub>]</i> or the form
3328 * <i>&lt;E&gt;[e<sub>1</sub>, &hellip;, e<sub>n</sub>]</i> is {@code List&lt; E&gt;}. The static 3362 * <i>&lt;E&gt;[e<sub>1</sub>, &hellip;, e<sub>n</sub>]</i> is {@code List&lt; E&gt;}. The static
3329 * type a list literal of the form <i><b>const</b> [e<sub>1</sub>, &hellip;, e <sub>n</sub>]</i> or 3363 * type a list literal of the form <i><b>const</b> [e<sub>1</sub>, &hellip;, e <sub>n</sub>]</i> or
3330 * the form <i>[e<sub>1</sub>, &hellip;, e<sub>n</sub>]</i> is {@code List&lt; dynamic&gt;}.</blockquote> 3364 * the form <i>[e<sub>1</sub>, &hellip;, e<sub>n</sub>]</i> is {@code List&lt; dynamic&gt;}.</blockquote>
3331 */ 3365 */
3332 Object visitListLiteral(ListLiteral node) { 3366 Object visitListLiteral(ListLiteral node) {
3333 TypeArgumentList typeArguments8 = node.typeArguments; 3367 TypeArgumentList typeArguments8 = node.typeArguments;
3334 if (typeArguments8 != null) { 3368 if (typeArguments8 != null) {
3335 NodeList<TypeName> arguments3 = typeArguments8.arguments; 3369 NodeList<TypeName> arguments4 = typeArguments8.arguments;
3336 if (arguments3 != null && arguments3.length == 1) { 3370 if (arguments4 != null && arguments4.length == 1) {
3337 TypeName argumentType = arguments3[0]; 3371 TypeName argumentType = arguments4[0];
3338 return recordType(node, _typeProvider.listType.substitute5(<Type2> [getT ype3(argumentType)])); 3372 return recordType(node, _typeProvider.listType.substitute5(<Type2> [getT ype3(argumentType)]));
3339 } 3373 }
3340 } 3374 }
3341 return recordType(node, _typeProvider.listType.substitute5(<Type2> [_dynamic Type])); 3375 return recordType(node, _typeProvider.listType.substitute5(<Type2> [_dynamic Type]));
3342 } 3376 }
3343 /** 3377 /**
3344 * The Dart Language Specification, 12.7: <blockquote>The static type of a map literal of the form 3378 * The Dart Language Specification, 12.7: <blockquote>The static type of a map literal of the form
3345 * <i><b>const</b> &lt;String, V&gt; {k<sub>1</sub>:e<sub>1</sub>, &hellip;, 3379 * <i><b>const</b> &lt;String, V&gt; {k<sub>1</sub>:e<sub>1</sub>, &hellip;,
3346 * k<sub>n</sub>:e<sub>n</sub>}</i> or the form <i>&lt;String, V&gt; {k<sub>1< /sub>:e<sub>1</sub>, 3380 * k<sub>n</sub>:e<sub>n</sub>}</i> or the form <i>&lt;String, V&gt; {k<sub>1< /sub>:e<sub>1</sub>,
3347 * &hellip;, k<sub>n</sub>:e<sub>n</sub>}</i> is {@code Map&lt;String, V&gt;}. The static type a 3381 * &hellip;, k<sub>n</sub>:e<sub>n</sub>}</i> is {@code Map&lt;String, V&gt;}. The static type a
3348 * map literal of the form <i><b>const</b> {k<sub>1</sub>:e<sub>1</sub>, &hell ip;, 3382 * map literal of the form <i><b>const</b> {k<sub>1</sub>:e<sub>1</sub>, &hell ip;,
3349 * k<sub>n</sub>:e<sub>n</sub>}</i> or the form <i>{k<sub>1</sub>:e<sub>1</sub >, &hellip;, 3383 * k<sub>n</sub>:e<sub>n</sub>}</i> or the form <i>{k<sub>1</sub>:e<sub>1</sub >, &hellip;,
3350 * k<sub>n</sub>:e<sub>n</sub>}</i> is {@code Map&lt;String, dynamic&gt;}. 3384 * k<sub>n</sub>:e<sub>n</sub>}</i> is {@code Map&lt;String, dynamic&gt;}.
3351 * <p> 3385 * <p>
3352 * It is a compile-time error if the first type argument to a map literal is n ot 3386 * It is a compile-time error if the first type argument to a map literal is n ot
3353 * <i>String</i>.</blockquote> 3387 * <i>String</i>.</blockquote>
3354 */ 3388 */
3355 Object visitMapLiteral(MapLiteral node) { 3389 Object visitMapLiteral(MapLiteral node) {
3356 TypeArgumentList typeArguments9 = node.typeArguments; 3390 TypeArgumentList typeArguments9 = node.typeArguments;
3357 if (typeArguments9 != null) { 3391 if (typeArguments9 != null) {
3358 NodeList<TypeName> arguments4 = typeArguments9.arguments; 3392 NodeList<TypeName> arguments5 = typeArguments9.arguments;
3359 if (arguments4 != null && arguments4.length == 2) { 3393 if (arguments5 != null && arguments5.length == 2) {
3360 TypeName keyType = arguments4[0]; 3394 TypeName keyType = arguments5[0];
3361 if (keyType != _typeProvider.stringType) { 3395 if (keyType != _typeProvider.stringType) {
3362 } 3396 }
3363 TypeName valueType = arguments4[1]; 3397 TypeName valueType = arguments5[1];
3364 return recordType(node, _typeProvider.mapType.substitute5(<Type2> [_type Provider.stringType, getType3(valueType)])); 3398 return recordType(node, _typeProvider.mapType.substitute5(<Type2> [_type Provider.stringType, getType3(valueType)]));
3365 } 3399 }
3366 } 3400 }
3367 return recordType(node, _typeProvider.mapType.substitute5(<Type2> [_typeProv ider.stringType, _dynamicType])); 3401 return recordType(node, _typeProvider.mapType.substitute5(<Type2> [_typeProv ider.stringType, _dynamicType]));
3368 } 3402 }
3369 /** 3403 /**
3370 * The Dart Language Specification, 12.15.1: <blockquote>An ordinary method in vocation <i>i</i> 3404 * The Dart Language Specification, 12.15.1: <blockquote>An ordinary method in vocation <i>i</i>
3371 * has the form <i>o.m(a<sub>1</sub>, &hellip;, a<sub>n</sub>, x<sub>n+1</sub> : a<sub>n+1</sub>, 3405 * has the form <i>o.m(a<sub>1</sub>, &hellip;, a<sub>n</sub>, x<sub>n+1</sub> : a<sub>n+1</sub>,
3372 * &hellip;, x<sub>n+k</sub>: a<sub>n+k</sub>)</i>. 3406 * &hellip;, x<sub>n+k</sub>: a<sub>n+k</sub>)</i>.
3373 * <p> 3407 * <p>
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
3435 * <p> 3469 * <p>
3436 * A postfix expression of the form <i>e1[e2]--</i> is equivalent to <i>(a, i) {var r = a[i]; a[i] 3470 * A postfix expression of the form <i>e1[e2]--</i> is equivalent to <i>(a, i) {var r = a[i]; a[i]
3437 * = r - 1; return r}(e1, e2)</i></blockquote> 3471 * = r - 1; return r}(e1, e2)</i></blockquote>
3438 */ 3472 */
3439 Object visitPostfixExpression(PostfixExpression node) => recordType(node, getT ype(node.operand)); 3473 Object visitPostfixExpression(PostfixExpression node) => recordType(node, getT ype(node.operand));
3440 /** 3474 /**
3441 * See {@link #visitSimpleIdentifier(SimpleIdentifier)}. 3475 * See {@link #visitSimpleIdentifier(SimpleIdentifier)}.
3442 */ 3476 */
3443 Object visitPrefixedIdentifier(PrefixedIdentifier node) { 3477 Object visitPrefixedIdentifier(PrefixedIdentifier node) {
3444 SimpleIdentifier prefixedIdentifier = node.identifier; 3478 SimpleIdentifier prefixedIdentifier = node.identifier;
3445 Element element24 = prefixedIdentifier.element; 3479 Element element25 = prefixedIdentifier.element;
3446 if (element24 is VariableElement) { 3480 if (element25 is VariableElement) {
3447 Type2 variableType = ((element24 as VariableElement)).type; 3481 Type2 variableType = ((element25 as VariableElement)).type;
3448 recordType(prefixedIdentifier, variableType); 3482 recordType(prefixedIdentifier, variableType);
3449 return recordType(node, variableType); 3483 return recordType(node, variableType);
3450 } else if (element24 is PropertyAccessorElement) { 3484 } else if (element25 is PropertyAccessorElement) {
3451 Type2 propertyType = getType2((element24 as PropertyAccessorElement)); 3485 Type2 propertyType = getType2((element25 as PropertyAccessorElement));
3452 recordType(prefixedIdentifier, propertyType); 3486 recordType(prefixedIdentifier, propertyType);
3453 return recordType(node, propertyType); 3487 return recordType(node, propertyType);
3454 } else if (element24 is MethodElement) { 3488 } else if (element25 is MethodElement) {
3455 Type2 returnType = ((element24 as MethodElement)).type; 3489 Type2 returnType = ((element25 as MethodElement)).type;
3456 recordType(prefixedIdentifier, returnType); 3490 recordType(prefixedIdentifier, returnType);
3457 return recordType(node, returnType); 3491 return recordType(node, returnType);
3458 } else { 3492 } else {
3459 } 3493 }
3460 recordType(prefixedIdentifier, _dynamicType); 3494 recordType(prefixedIdentifier, _dynamicType);
3461 return recordType(node, _dynamicType); 3495 return recordType(node, _dynamicType);
3462 } 3496 }
3463 /** 3497 /**
3464 * The Dart Language Specification, 12.27: <blockquote>A unary expression <i>u </i> of the form 3498 * The Dart Language Specification, 12.27: <blockquote>A unary expression <i>u </i> of the form
3465 * <i>op e</i> is equivalent to a method invocation <i>expression e.op()</i>. An expression of the 3499 * <i>op e</i> is equivalent to a method invocation <i>expression e.op()</i>. An expression of the
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
3510 * The static type of <i>i</i> is the declared return type of <i>C.m</i> if it exists or dynamic 3544 * The static type of <i>i</i> is the declared return type of <i>C.m</i> if it exists or dynamic
3511 * otherwise. 3545 * otherwise.
3512 * <p> 3546 * <p>
3513 * ... a top-level getter invocation <i>i</i> of the form <i>m</i>, where <i>m </i> is an 3547 * ... a top-level getter invocation <i>i</i> of the form <i>m</i>, where <i>m </i> is an
3514 * identifier ... 3548 * identifier ...
3515 * <p> 3549 * <p>
3516 * The static type of <i>i</i> is the declared return type of <i>m</i>.</block quote> 3550 * The static type of <i>i</i> is the declared return type of <i>m</i>.</block quote>
3517 */ 3551 */
3518 Object visitPropertyAccess(PropertyAccess node) { 3552 Object visitPropertyAccess(PropertyAccess node) {
3519 SimpleIdentifier propertyName2 = node.propertyName; 3553 SimpleIdentifier propertyName2 = node.propertyName;
3520 Element element25 = propertyName2.element; 3554 Element element26 = propertyName2.element;
3521 if (element25 is MethodElement) { 3555 if (element26 is MethodElement) {
3522 FunctionType type15 = ((element25 as MethodElement)).type; 3556 FunctionType type15 = ((element26 as MethodElement)).type;
3523 recordType(propertyName2, type15); 3557 recordType(propertyName2, type15);
3524 return recordType(node, type15); 3558 return recordType(node, type15);
3525 } else if (element25 is PropertyAccessorElement) { 3559 } else if (element26 is PropertyAccessorElement) {
3526 Type2 propertyType = getType2((element25 as PropertyAccessorElement)); 3560 Type2 propertyType = getType2((element26 as PropertyAccessorElement));
3527 recordType(propertyName2, propertyType); 3561 recordType(propertyName2, propertyType);
3528 return recordType(node, propertyType); 3562 return recordType(node, propertyType);
3529 } else { 3563 } else {
3530 } 3564 }
3531 recordType(propertyName2, _dynamicType); 3565 recordType(propertyName2, _dynamicType);
3532 return recordType(node, _dynamicType); 3566 return recordType(node, _dynamicType);
3533 } 3567 }
3534 /** 3568 /**
3535 * The Dart Language Specification, 12.30: <blockquote>Evaluation of an identi fier expression 3569 * The Dart Language Specification, 12.30: <blockquote>Evaluation of an identi fier expression
3536 * <i>e</i> of the form <i>id</i> proceeds as follows: 3570 * <i>e</i> of the form <i>id</i> proceeds as follows:
(...skipping 30 matching lines...) Expand all
3567 * <li>If <i>d</i> is the declaration of a top level getter, then <i>e</i> is equivalent to the 3601 * <li>If <i>d</i> is the declaration of a top level getter, then <i>e</i> is equivalent to the
3568 * getter invocation <i>id</i>. 3602 * getter invocation <i>id</i>.
3569 * <li>Otherwise, if <i>e</i> occurs inside a top level or static function (be it function, 3603 * <li>Otherwise, if <i>e</i> occurs inside a top level or static function (be it function,
3570 * method, getter, or setter) or variable initializer, evaluation of e causes a NoSuchMethodError 3604 * method, getter, or setter) or variable initializer, evaluation of e causes a NoSuchMethodError
3571 * to be thrown. 3605 * to be thrown.
3572 * <li>Otherwise <i>e</i> is equivalent to the property extraction <i>this.id< /i>. 3606 * <li>Otherwise <i>e</i> is equivalent to the property extraction <i>this.id< /i>.
3573 * </ul> 3607 * </ul>
3574 * </blockquote> 3608 * </blockquote>
3575 */ 3609 */
3576 Object visitSimpleIdentifier(SimpleIdentifier node) { 3610 Object visitSimpleIdentifier(SimpleIdentifier node) {
3577 Element element26 = node.element; 3611 Element element27 = node.element;
3578 if (element26 == null) { 3612 if (element27 == null) {
3579 return recordType(node, _dynamicType); 3613 return recordType(node, _dynamicType);
3580 } else if (element26 is ClassElement) { 3614 } else if (element27 is ClassElement) {
3581 if (isTypeName(node)) { 3615 if (isNotTypeLiteral(node)) {
3582 return recordType(node, ((element26 as ClassElement)).type); 3616 return recordType(node, ((element27 as ClassElement)).type);
3583 } 3617 }
3584 return recordType(node, _typeProvider.typeType); 3618 return recordType(node, _typeProvider.typeType);
3585 } else if (element26 is TypeVariableElement) { 3619 } else if (element27 is TypeVariableElement) {
3586 return recordType(node, ((element26 as TypeVariableElement)).type); 3620 return recordType(node, ((element27 as TypeVariableElement)).type);
3587 } else if (element26 is TypeAliasElement) { 3621 } else if (element27 is FunctionTypeAliasElement) {
3588 return recordType(node, ((element26 as TypeAliasElement)).type); 3622 return recordType(node, ((element27 as FunctionTypeAliasElement)).type);
3589 } else if (element26 is VariableElement) { 3623 } else if (element27 is VariableElement) {
3590 return recordType(node, ((element26 as VariableElement)).type); 3624 return recordType(node, ((element27 as VariableElement)).type);
3591 } else if (element26 is MethodElement) { 3625 } else if (element27 is MethodElement) {
3592 return recordType(node, ((element26 as MethodElement)).type); 3626 return recordType(node, ((element27 as MethodElement)).type);
3593 } else if (element26 is PropertyAccessorElement) { 3627 } else if (element27 is PropertyAccessorElement) {
3594 return recordType(node, getType2((element26 as PropertyAccessorElement))); 3628 return recordType(node, getType2((element27 as PropertyAccessorElement)));
3595 } else if (element26 is ExecutableElement) { 3629 } else if (element27 is ExecutableElement) {
3596 return recordType(node, ((element26 as ExecutableElement)).type); 3630 return recordType(node, ((element27 as ExecutableElement)).type);
3597 } else if (element26 is PrefixElement) { 3631 } else if (element27 is PrefixElement) {
3598 return null; 3632 return null;
3599 } else { 3633 } else {
3600 return recordType(node, _dynamicType); 3634 return recordType(node, _dynamicType);
3601 } 3635 }
3602 } 3636 }
3603 /** 3637 /**
3604 * The Dart Language Specification, 12.5: <blockquote>The static type of a str ing literal is{@code String}.</blockquote> 3638 * The Dart Language Specification, 12.5: <blockquote>The static type of a str ing literal is{@code String}.</blockquote>
3605 */ 3639 */
3606 Object visitSimpleStringLiteral(SimpleStringLiteral node) => recordType(node, _typeProvider.stringType); 3640 Object visitSimpleStringLiteral(SimpleStringLiteral node) => recordType(node, _typeProvider.stringType);
3607 /** 3641 /**
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
3703 * @return the type represented by the type name 3737 * @return the type represented by the type name
3704 */ 3738 */
3705 Type2 getType3(TypeName typeName) { 3739 Type2 getType3(TypeName typeName) {
3706 Type2 type16 = typeName.type; 3740 Type2 type16 = typeName.type;
3707 if (type16 == null) { 3741 if (type16 == null) {
3708 return _dynamicType; 3742 return _dynamicType;
3709 } 3743 }
3710 return type16; 3744 return type16;
3711 } 3745 }
3712 /** 3746 /**
3713 * Return {@code true} if the given node is being used as the name of a type. 3747 * Return {@code true} if the given node is not a type literal.
3714 * @param node the node being tested 3748 * @param node the node being tested
3715 * @return {@code true} if the given node is being used as the name of a type 3749 * @return {@code true} if the given node is not a type literal
3716 */ 3750 */
3717 bool isTypeName(SimpleIdentifier node) { 3751 bool isNotTypeLiteral(SimpleIdentifier node) {
3718 ASTNode parent15 = node.parent; 3752 ASTNode parent15 = node.parent;
3719 return parent15 is TypeName || (parent15 is PrefixedIdentifier && parent15.p arent is TypeName) || (parent15 is MethodInvocation && identical(node, ((parent1 5 as MethodInvocation)).target)); 3753 return parent15 is TypeName || (parent15 is PrefixedIdentifier && (parent15. parent is TypeName || identical(((parent15 as PrefixedIdentifier)).prefix, node) )) || (parent15 is PropertyAccess && identical(((parent15 as PropertyAccess)).ta rget, node)) || (parent15 is MethodInvocation && identical(node, ((parent15 as M ethodInvocation)).target));
3720 } 3754 }
3721 /** 3755 /**
3722 * Record that the static type of the given node is the type of the second arg ument to the method 3756 * Record that the static type of the given node is the type of the second arg ument to the method
3723 * represented by the given element. 3757 * represented by the given element.
3724 * @param expression the node whose type is to be recorded 3758 * @param expression the node whose type is to be recorded
3725 * @param element the element representing the method invoked by the given nod e 3759 * @param element the element representing the method invoked by the given nod e
3726 */ 3760 */
3727 Object recordArgumentType(IndexExpression expression, MethodElement element) { 3761 Object recordArgumentType(IndexExpression expression, MethodElement element) {
3728 if (element != null) { 3762 if (element != null) {
3729 List<ParameterElement> parameters12 = element.parameters; 3763 List<ParameterElement> parameters12 = element.parameters;
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
4014 SimpleIdentifier exception = node.exceptionParameter; 4048 SimpleIdentifier exception = node.exceptionParameter;
4015 if (exception != null) { 4049 if (exception != null) {
4016 TypeName exceptionTypeName = node.exceptionType; 4050 TypeName exceptionTypeName = node.exceptionType;
4017 Type2 exceptionType; 4051 Type2 exceptionType;
4018 if (exceptionTypeName == null) { 4052 if (exceptionTypeName == null) {
4019 exceptionType = typeProvider.objectType; 4053 exceptionType = typeProvider.objectType;
4020 } else { 4054 } else {
4021 exceptionType = getType4(exceptionTypeName); 4055 exceptionType = getType4(exceptionTypeName);
4022 } 4056 }
4023 recordType(exception, exceptionType); 4057 recordType(exception, exceptionType);
4024 Element element27 = exception.element; 4058 Element element28 = exception.element;
4025 if (element27 is VariableElementImpl) { 4059 if (element28 is VariableElementImpl) {
4026 ((element27 as VariableElementImpl)).type = exceptionType; 4060 ((element28 as VariableElementImpl)).type = exceptionType;
4027 } else { 4061 } else {
4028 } 4062 }
4029 } 4063 }
4030 SimpleIdentifier stackTrace = node.stackTraceParameter; 4064 SimpleIdentifier stackTrace = node.stackTraceParameter;
4031 if (stackTrace != null) { 4065 if (stackTrace != null) {
4032 recordType(stackTrace, typeProvider.stackTraceType); 4066 recordType(stackTrace, typeProvider.stackTraceType);
4033 } 4067 }
4034 return null; 4068 return null;
4035 } 4069 }
4036 Object visitClassDeclaration(ClassDeclaration node) { 4070 Object visitClassDeclaration(ClassDeclaration node) {
(...skipping 27 matching lines...) Expand all
4064 superclassType = typeProvider.objectType; 4098 superclassType = typeProvider.objectType;
4065 } 4099 }
4066 if (classElement != null && superclassType != null) { 4100 if (classElement != null && superclassType != null) {
4067 classElement.supertype = superclassType; 4101 classElement.supertype = superclassType;
4068 } 4102 }
4069 resolve(classElement, node.withClause, node.implementsClause); 4103 resolve(classElement, node.withClause, node.implementsClause);
4070 return null; 4104 return null;
4071 } 4105 }
4072 Object visitConstructorDeclaration(ConstructorDeclaration node) { 4106 Object visitConstructorDeclaration(ConstructorDeclaration node) {
4073 super.visitConstructorDeclaration(node); 4107 super.visitConstructorDeclaration(node);
4074 ExecutableElementImpl element28 = node.element as ExecutableElementImpl; 4108 ExecutableElementImpl element29 = node.element as ExecutableElementImpl;
4075 FunctionTypeImpl type = new FunctionTypeImpl.con1(element28); 4109 FunctionTypeImpl type = new FunctionTypeImpl.con1(element29);
4076 setTypeInformation(type, null, element28.parameters); 4110 setTypeInformation(type, null, element29.parameters);
4077 type.returnType = ((element28.enclosingElement as ClassElement)).type; 4111 type.returnType = ((element29.enclosingElement as ClassElement)).type;
4078 element28.type = type; 4112 element29.type = type;
4079 return null; 4113 return null;
4080 } 4114 }
4081 Object visitDeclaredIdentifier(DeclaredIdentifier node) { 4115 Object visitDeclaredIdentifier(DeclaredIdentifier node) {
4082 super.visitDeclaredIdentifier(node); 4116 super.visitDeclaredIdentifier(node);
4083 Type2 declaredType; 4117 Type2 declaredType;
4084 TypeName typeName = node.type; 4118 TypeName typeName = node.type;
4085 if (typeName == null) { 4119 if (typeName == null) {
4086 declaredType = _dynamicType; 4120 declaredType = _dynamicType;
4087 } else { 4121 } else {
4088 declaredType = getType4(typeName); 4122 declaredType = getType4(typeName);
4089 } 4123 }
4090 LocalVariableElementImpl element29 = node.element as LocalVariableElementImp l; 4124 LocalVariableElementImpl element30 = node.element as LocalVariableElementImp l;
4091 element29.type = declaredType; 4125 element30.type = declaredType;
4092 return null; 4126 return null;
4093 } 4127 }
4094 Object visitDefaultFormalParameter(DefaultFormalParameter node) { 4128 Object visitDefaultFormalParameter(DefaultFormalParameter node) {
4095 super.visitDefaultFormalParameter(node); 4129 super.visitDefaultFormalParameter(node);
4096 return null; 4130 return null;
4097 } 4131 }
4098 Object visitFieldFormalParameter(FieldFormalParameter node) { 4132 Object visitFieldFormalParameter(FieldFormalParameter node) {
4099 super.visitFieldFormalParameter(node); 4133 super.visitFieldFormalParameter(node);
4100 Element element30 = node.identifier.element; 4134 Element element31 = node.identifier.element;
4101 if (element30 is ParameterElementImpl) { 4135 if (element31 is ParameterElementImpl) {
4102 ParameterElementImpl parameter = element30 as ParameterElementImpl; 4136 ParameterElementImpl parameter = element31 as ParameterElementImpl;
4103 Type2 type; 4137 Type2 type;
4104 TypeName typeName = node.type; 4138 TypeName typeName = node.type;
4105 if (typeName == null) { 4139 if (typeName == null) {
4106 type = _dynamicType; 4140 type = _dynamicType;
4107 } else { 4141 } else {
4108 type = getType4(typeName); 4142 type = getType4(typeName);
4109 } 4143 }
4110 parameter.type = type; 4144 parameter.type = type;
4111 } else { 4145 } else {
4112 } 4146 }
4113 return null; 4147 return null;
4114 } 4148 }
4115 Object visitFunctionDeclaration(FunctionDeclaration node) { 4149 Object visitFunctionDeclaration(FunctionDeclaration node) {
4116 super.visitFunctionDeclaration(node); 4150 super.visitFunctionDeclaration(node);
4117 ExecutableElementImpl element31 = node.element as ExecutableElementImpl; 4151 ExecutableElementImpl element32 = node.element as ExecutableElementImpl;
4118 FunctionTypeImpl type = new FunctionTypeImpl.con1(element31); 4152 FunctionTypeImpl type = new FunctionTypeImpl.con1(element32);
4119 setTypeInformation(type, node.returnType, element31.parameters); 4153 setTypeInformation(type, node.returnType, element32.parameters);
4120 element31.type = type; 4154 element32.type = type;
4121 return null; 4155 return null;
4122 } 4156 }
4123 Object visitFunctionTypeAlias(FunctionTypeAlias node) { 4157 Object visitFunctionTypeAlias(FunctionTypeAlias node) {
4124 super.visitFunctionTypeAlias(node); 4158 super.visitFunctionTypeAlias(node);
4125 TypeAliasElementImpl element32 = node.element as TypeAliasElementImpl; 4159 FunctionTypeAliasElementImpl element33 = node.element as FunctionTypeAliasEl ementImpl;
4126 FunctionTypeImpl type18 = element32.type as FunctionTypeImpl; 4160 FunctionTypeImpl type18 = element33.type as FunctionTypeImpl;
4127 setTypeInformation(type18, node.returnType, element32.parameters); 4161 setTypeInformation(type18, node.returnType, element33.parameters);
4128 return null; 4162 return null;
4129 } 4163 }
4130 Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { 4164 Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) {
4131 super.visitFunctionTypedFormalParameter(node); 4165 super.visitFunctionTypedFormalParameter(node);
4132 ParameterElementImpl element33 = node.identifier.element as ParameterElement Impl; 4166 ParameterElementImpl element34 = node.identifier.element as ParameterElement Impl;
4133 FunctionTypeImpl type = new FunctionTypeImpl.con1((null as ExecutableElement )); 4167 FunctionTypeImpl type = new FunctionTypeImpl.con1((null as ExecutableElement ));
4134 setTypeInformation(type, node.returnType, getElements(node.parameters)); 4168 setTypeInformation(type, node.returnType, getElements(node.parameters));
4135 element33.type = type; 4169 element34.type = type;
4136 return null; 4170 return null;
4137 } 4171 }
4138 Object visitMethodDeclaration(MethodDeclaration node) { 4172 Object visitMethodDeclaration(MethodDeclaration node) {
4139 super.visitMethodDeclaration(node); 4173 super.visitMethodDeclaration(node);
4140 ExecutableElementImpl element34 = node.element as ExecutableElementImpl; 4174 ExecutableElementImpl element35 = node.element as ExecutableElementImpl;
4141 FunctionTypeImpl type = new FunctionTypeImpl.con1(element34); 4175 FunctionTypeImpl type = new FunctionTypeImpl.con1(element35);
4142 setTypeInformation(type, node.returnType, element34.parameters); 4176 setTypeInformation(type, node.returnType, element35.parameters);
4143 element34.type = type; 4177 element35.type = type;
4144 if (element34 is PropertyAccessorElementImpl) { 4178 if (element35 is PropertyAccessorElementImpl) {
4145 PropertyAccessorElementImpl accessor = element34 as PropertyAccessorElemen tImpl; 4179 PropertyAccessorElementImpl accessor = element35 as PropertyAccessorElemen tImpl;
4146 PropertyInducingElementImpl variable5 = accessor.variable as PropertyInduc ingElementImpl; 4180 PropertyInducingElementImpl variable5 = accessor.variable as PropertyInduc ingElementImpl;
4147 if (accessor.isGetter()) { 4181 if (accessor.isGetter()) {
4148 variable5.type = type.returnType; 4182 variable5.type = type.returnType;
4149 } else if (variable5.type == null) { 4183 } else if (variable5.type == null) {
4150 List<Type2> parameterTypes = type.normalParameterTypes; 4184 List<Type2> parameterTypes = type.normalParameterTypes;
4151 if (parameterTypes != null && parameterTypes.length > 0) { 4185 if (parameterTypes != null && parameterTypes.length > 0) {
4152 variable5.type = parameterTypes[0]; 4186 variable5.type = parameterTypes[0];
4153 } 4187 }
4154 } 4188 }
4155 } 4189 }
4156 return null; 4190 return null;
4157 } 4191 }
4158 Object visitSimpleFormalParameter(SimpleFormalParameter node) { 4192 Object visitSimpleFormalParameter(SimpleFormalParameter node) {
4159 super.visitSimpleFormalParameter(node); 4193 super.visitSimpleFormalParameter(node);
4160 Type2 declaredType; 4194 Type2 declaredType;
4161 TypeName typeName = node.type; 4195 TypeName typeName = node.type;
4162 if (typeName == null) { 4196 if (typeName == null) {
4163 declaredType = _dynamicType; 4197 declaredType = _dynamicType;
4164 } else { 4198 } else {
4165 declaredType = getType4(typeName); 4199 declaredType = getType4(typeName);
4166 } 4200 }
4167 Element element35 = node.identifier.element; 4201 Element element36 = node.identifier.element;
4168 if (element35 is ParameterElement) { 4202 if (element36 is ParameterElement) {
4169 ((element35 as ParameterElementImpl)).type = declaredType; 4203 ((element36 as ParameterElementImpl)).type = declaredType;
4170 } else { 4204 } else {
4171 } 4205 }
4172 return null; 4206 return null;
4173 } 4207 }
4174 Object visitTypeName(TypeName node) { 4208 Object visitTypeName(TypeName node) {
4175 super.visitTypeName(node); 4209 super.visitTypeName(node);
4176 Identifier typeName = node.name; 4210 Identifier typeName = node.name;
4177 TypeArgumentList argumentList = node.typeArguments; 4211 TypeArgumentList argumentList = node.typeArguments;
4178 Element element = nameScope.lookup(typeName, definingLibrary); 4212 Element element = nameScope.lookup(typeName, definingLibrary);
4179 if (element == null) { 4213 if (element == null) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
4213 if (element == null) { 4247 if (element == null) {
4214 setElement(typeName, _dynamicType.element); 4248 setElement(typeName, _dynamicType.element);
4215 typeName.staticType = _dynamicType; 4249 typeName.staticType = _dynamicType;
4216 node.type = _dynamicType; 4250 node.type = _dynamicType;
4217 return null; 4251 return null;
4218 } 4252 }
4219 Type2 type = null; 4253 Type2 type = null;
4220 if (element is ClassElement) { 4254 if (element is ClassElement) {
4221 setElement(typeName, element); 4255 setElement(typeName, element);
4222 type = ((element as ClassElement)).type; 4256 type = ((element as ClassElement)).type;
4223 } else if (element is TypeAliasElement) { 4257 } else if (element is FunctionTypeAliasElement) {
4224 setElement(typeName, element); 4258 setElement(typeName, element);
4225 type = ((element as TypeAliasElement)).type; 4259 type = ((element as FunctionTypeAliasElement)).type;
4226 } else if (element is TypeVariableElement) { 4260 } else if (element is TypeVariableElement) {
4227 setElement(typeName, element); 4261 setElement(typeName, element);
4228 type = ((element as TypeVariableElement)).type; 4262 type = ((element as TypeVariableElement)).type;
4229 if (argumentList != null) { 4263 if (argumentList != null) {
4230 } 4264 }
4231 } else { 4265 } else {
4232 setElement(typeName, _dynamicType.element); 4266 setElement(typeName, _dynamicType.element);
4233 typeName.staticType = _dynamicType; 4267 typeName.staticType = _dynamicType;
4234 node.type = _dynamicType; 4268 node.type = _dynamicType;
4235 return null; 4269 return null;
4236 } 4270 }
4237 if (argumentList != null) { 4271 if (argumentList != null) {
4238 NodeList<TypeName> arguments5 = argumentList.arguments; 4272 NodeList<TypeName> arguments6 = argumentList.arguments;
4239 int argumentCount = arguments5.length; 4273 int argumentCount = arguments6.length;
4240 List<Type2> parameters = getTypeArguments(type); 4274 List<Type2> parameters = getTypeArguments(type);
4241 int parameterCount = parameters.length; 4275 int parameterCount = parameters.length;
4242 int count = Math.min(argumentCount, parameterCount); 4276 int count = Math.min(argumentCount, parameterCount);
4243 List<Type2> typeArguments = new List<Type2>(); 4277 List<Type2> typeArguments = new List<Type2>();
4244 for (int i = 0; i < count; i++) { 4278 for (int i = 0; i < count; i++) {
4245 Type2 argumentType = getType4(arguments5[i]); 4279 Type2 argumentType = getType4(arguments6[i]);
4246 if (argumentType != null) { 4280 if (argumentType != null) {
4247 typeArguments.add(argumentType); 4281 typeArguments.add(argumentType);
4248 } 4282 }
4249 } 4283 }
4250 if (argumentCount != parameterCount) { 4284 if (argumentCount != parameterCount) {
4251 reportError(getInvalidTypeParametersErrorCode(node), node, [typeName.nam e, argumentCount, parameterCount]); 4285 reportError(getInvalidTypeParametersErrorCode(node), node, [typeName.nam e, argumentCount, parameterCount]);
4252 } 4286 }
4253 argumentCount = typeArguments.length; 4287 argumentCount = typeArguments.length;
4254 if (argumentCount < parameterCount) { 4288 if (argumentCount < parameterCount) {
4255 for (int i = argumentCount; i < parameterCount; i++) { 4289 for (int i = argumentCount; i < parameterCount; i++) {
(...skipping 26 matching lines...) Expand all
4282 } 4316 }
4283 Object visitVariableDeclaration(VariableDeclaration node) { 4317 Object visitVariableDeclaration(VariableDeclaration node) {
4284 super.visitVariableDeclaration(node); 4318 super.visitVariableDeclaration(node);
4285 Type2 declaredType; 4319 Type2 declaredType;
4286 TypeName typeName = ((node.parent as VariableDeclarationList)).type; 4320 TypeName typeName = ((node.parent as VariableDeclarationList)).type;
4287 if (typeName == null) { 4321 if (typeName == null) {
4288 declaredType = _dynamicType; 4322 declaredType = _dynamicType;
4289 } else { 4323 } else {
4290 declaredType = getType4(typeName); 4324 declaredType = getType4(typeName);
4291 } 4325 }
4292 Element element36 = node.name.element; 4326 Element element37 = node.name.element;
4293 if (element36 is VariableElement) { 4327 if (element37 is VariableElement) {
4294 ((element36 as VariableElementImpl)).type = declaredType; 4328 ((element37 as VariableElementImpl)).type = declaredType;
4295 if (element36 is FieldElement) { 4329 if (element37 is FieldElement) {
4296 FieldElement field = element36 as FieldElement; 4330 FieldElement field = element37 as FieldElement;
4297 PropertyAccessorElementImpl getter5 = field.getter as PropertyAccessorEl ementImpl; 4331 PropertyAccessorElementImpl getter5 = field.getter as PropertyAccessorEl ementImpl;
4298 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter5); 4332 FunctionTypeImpl getterType = new FunctionTypeImpl.con1(getter5);
4299 getterType.returnType = declaredType; 4333 getterType.returnType = declaredType;
4300 getter5.type = getterType; 4334 getter5.type = getterType;
4301 PropertyAccessorElementImpl setter4 = field.setter as PropertyAccessorEl ementImpl; 4335 PropertyAccessorElementImpl setter4 = field.setter as PropertyAccessorEl ementImpl;
4302 if (setter4 != null) { 4336 if (setter4 != null) {
4303 FunctionTypeImpl setterType = new FunctionTypeImpl.con1(setter4); 4337 FunctionTypeImpl setterType = new FunctionTypeImpl.con1(setter4);
4304 setterType.returnType = VoidTypeImpl.instance; 4338 setterType.returnType = VoidTypeImpl.instance;
4305 setterType.normalParameterTypes = <Type2> [declaredType]; 4339 setterType.normalParameterTypes = <Type2> [declaredType];
4306 setter4.type = setterType; 4340 setter4.type = setterType;
4307 } 4341 }
4308 } 4342 }
4309 } else { 4343 } else {
4310 } 4344 }
4311 return null; 4345 return null;
4312 } 4346 }
4313 /** 4347 /**
4314 * Return the class element that represents the class whose name was provided. 4348 * Return the class element that represents the class whose name was provided.
4315 * @param identifier the name from the declaration of a class 4349 * @param identifier the name from the declaration of a class
4316 * @return the class element that represents the class 4350 * @return the class element that represents the class
4317 */ 4351 */
4318 ClassElementImpl getClassElement(SimpleIdentifier identifier) { 4352 ClassElementImpl getClassElement(SimpleIdentifier identifier) {
4319 if (identifier == null) { 4353 if (identifier == null) {
4320 return null; 4354 return null;
4321 } 4355 }
4322 Element element37 = identifier.element; 4356 Element element38 = identifier.element;
4323 if (element37 is! ClassElementImpl) { 4357 if (element38 is! ClassElementImpl) {
4324 return null; 4358 return null;
4325 } 4359 }
4326 return element37 as ClassElementImpl; 4360 return element38 as ClassElementImpl;
4327 } 4361 }
4328 /** 4362 /**
4329 * Return an array containing all of the elements associated with the paramete rs in the given 4363 * Return an array containing all of the elements associated with the paramete rs in the given
4330 * list. 4364 * list.
4331 * @param parameterList the list of parameters whose elements are to be return ed 4365 * @param parameterList the list of parameters whose elements are to be return ed
4332 * @return the elements associated with the parameters 4366 * @return the elements associated with the parameters
4333 */ 4367 */
4334 List<ParameterElement> getElements(FormalParameterList parameterList) { 4368 List<ParameterElement> getElements(FormalParameterList parameterList) {
4335 List<ParameterElement> elements = new List<ParameterElement>(); 4369 List<ParameterElement> elements = new List<ParameterElement>();
4336 for (FormalParameter parameter in parameterList.parameters) { 4370 for (FormalParameter parameter in parameterList.parameters) {
4337 ParameterElement element38 = parameter.identifier.element as ParameterElem ent; 4371 ParameterElement element39 = parameter.identifier.element as ParameterElem ent;
4338 if (element38 != null) { 4372 if (element39 != null) {
4339 elements.add(element38); 4373 elements.add(element39);
4340 } 4374 }
4341 } 4375 }
4342 return new List.from(elements); 4376 return new List.from(elements);
4343 } 4377 }
4344 /** 4378 /**
4345 * The number of type arguments in the given type name does not match the numb er of parameters in 4379 * The number of type arguments in the given type name does not match the numb er of parameters in
4346 * the corresponding class element. Return the error code that should be used to report this 4380 * the corresponding class element. Return the error code that should be used to report this
4347 * error. 4381 * error.
4348 * @param node the type name with the wrong number of type arguments 4382 * @param node the type name with the wrong number of type arguments
4349 * @return the error code that should be used to report that the wrong number of type arguments 4383 * @return the error code that should be used to report that the wrong number of type arguments
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
4447 * @param undefinedError the error to produce if the type name is not defined 4481 * @param undefinedError the error to produce if the type name is not defined
4448 * @param nonTypeError the error to produce if the type name is defined to be something other than 4482 * @param nonTypeError the error to produce if the type name is defined to be something other than
4449 * a type 4483 * a type
4450 * @param nonInterfaceType the error to produce if the type is not an interfac e type 4484 * @param nonInterfaceType the error to produce if the type is not an interfac e type
4451 * @return the type specified by the type name 4485 * @return the type specified by the type name
4452 */ 4486 */
4453 InterfaceType resolveType(TypeName typeName, ErrorCode undefinedError, ErrorCo de nonTypeError, ErrorCode nonInterfaceType) { 4487 InterfaceType resolveType(TypeName typeName, ErrorCode undefinedError, ErrorCo de nonTypeError, ErrorCode nonInterfaceType) {
4454 Identifier name16 = typeName.name; 4488 Identifier name16 = typeName.name;
4455 Element element = nameScope.lookup(name16, definingLibrary); 4489 Element element = nameScope.lookup(name16, definingLibrary);
4456 if (element == null) { 4490 if (element == null) {
4457 reportError(undefinedError, name16, []); 4491 reportError(undefinedError, name16, [name16.name]);
4458 } else if (element is ClassElement) { 4492 } else if (element is ClassElement) {
4459 Type2 classType = ((element as ClassElement)).type; 4493 Type2 classType = ((element as ClassElement)).type;
4460 typeName.type = classType; 4494 typeName.type = classType;
4461 if (classType is InterfaceType) { 4495 if (classType is InterfaceType) {
4462 return classType as InterfaceType; 4496 return classType as InterfaceType;
4463 } 4497 }
4464 reportError(nonInterfaceType, name16, []); 4498 reportError(nonInterfaceType, name16, [name16.name]);
4465 } else if (element is MultiplyDefinedElement) { 4499 } else if (element is MultiplyDefinedElement) {
4466 List<Element> elements = ((element as MultiplyDefinedElement)).conflicting Elements; 4500 List<Element> elements = ((element as MultiplyDefinedElement)).conflicting Elements;
4467 InterfaceType type = getType(elements); 4501 InterfaceType type = getType(elements);
4468 if (type != null) { 4502 if (type != null) {
4469 typeName.type = type; 4503 typeName.type = type;
4470 } 4504 }
4471 } else { 4505 } else {
4472 reportError(nonTypeError, name16, []); 4506 reportError(nonTypeError, name16, [name16.name]);
4473 } 4507 }
4474 return null; 4508 return null;
4475 } 4509 }
4476 /** 4510 /**
4477 * Resolve the types in the given list of type names. 4511 * Resolve the types in the given list of type names.
4478 * @param typeNames the type names to be resolved 4512 * @param typeNames the type names to be resolved
4479 * @param undefinedError the error to produce if the type name is not defined 4513 * @param undefinedError the error to produce if the type name is not defined
4480 * @param nonTypeError the error to produce if the type name is defined to be something other than 4514 * @param nonTypeError the error to produce if the type name is defined to be something other than
4481 * a type 4515 * a type
4482 * @param nonInterfaceType the error to produce if the type is not an interfac e type 4516 * @param nonInterfaceType the error to produce if the type is not an interfac e type
4483 * @return an array containing all of the types that were resolved. 4517 * @return an array containing all of the types that were resolved.
4484 */ 4518 */
4485 List<InterfaceType> resolveTypes(NodeList<TypeName> typeNames, ErrorCode undef inedError, ErrorCode nonTypeError, ErrorCode nonInterfaceType) { 4519 List<InterfaceType> resolveTypes(NodeList<TypeName> typeNames, ErrorCode undef inedError, ErrorCode nonTypeError, ErrorCode nonInterfaceType) {
4486 List<InterfaceType> types = new List<InterfaceType>(); 4520 List<InterfaceType> types = new List<InterfaceType>();
4487 for (TypeName typeName in typeNames) { 4521 for (TypeName typeName in typeNames) {
4488 InterfaceType type = resolveType(typeName, undefinedError, nonTypeError, n onInterfaceType); 4522 InterfaceType type = resolveType(typeName, undefinedError, nonTypeError, n onInterfaceType);
4489 if (type != null) { 4523 if (type != null) {
4490 types.add(type); 4524 types.add(type);
4491 } 4525 }
4492 } 4526 }
4493 return new List.from(types); 4527 return new List.from(types);
4494 } 4528 }
4495 void setElement(Identifier typeName, Element element51) { 4529 void setElement(Identifier typeName, Element element54) {
4496 if (element51 != null) { 4530 if (element54 != null) {
4497 if (typeName is SimpleIdentifier) { 4531 if (typeName is SimpleIdentifier) {
4498 ((typeName as SimpleIdentifier)).element = element51; 4532 ((typeName as SimpleIdentifier)).element = element54;
4499 } else if (typeName is PrefixedIdentifier) { 4533 } else if (typeName is PrefixedIdentifier) {
4500 PrefixedIdentifier identifier = typeName as PrefixedIdentifier; 4534 PrefixedIdentifier identifier = typeName as PrefixedIdentifier;
4501 identifier.identifier.element = element51; 4535 identifier.identifier.element = element54;
4502 SimpleIdentifier prefix9 = identifier.prefix; 4536 SimpleIdentifier prefix9 = identifier.prefix;
4503 Element prefixElement = nameScope.lookup(prefix9, definingLibrary); 4537 Element prefixElement = nameScope.lookup(prefix9, definingLibrary);
4504 if (prefixElement != null) { 4538 if (prefixElement != null) {
4505 prefix9.element = prefixElement; 4539 prefix9.element = prefixElement;
4506 } 4540 }
4507 } 4541 }
4508 } 4542 }
4509 } 4543 }
4510 /** 4544 /**
4511 * Set the return type and parameter type information for the given function t ype based on the 4545 * Set the return type and parameter type information for the given function t ype based on the
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
4651 * Instances of the class {@code FunctionTypeScope} implement the scope defined by a function type 4685 * Instances of the class {@code FunctionTypeScope} implement the scope defined by a function type
4652 * alias. 4686 * alias.
4653 * @coverage dart.engine.resolver 4687 * @coverage dart.engine.resolver
4654 */ 4688 */
4655 class FunctionTypeScope extends EnclosedScope { 4689 class FunctionTypeScope extends EnclosedScope {
4656 /** 4690 /**
4657 * Initialize a newly created scope enclosed within another scope. 4691 * Initialize a newly created scope enclosed within another scope.
4658 * @param enclosingScope the scope in which this scope is lexically enclosed 4692 * @param enclosingScope the scope in which this scope is lexically enclosed
4659 * @param typeElement the element representing the type alias represented by t his scope 4693 * @param typeElement the element representing the type alias represented by t his scope
4660 */ 4694 */
4661 FunctionTypeScope(Scope enclosingScope, TypeAliasElement typeElement) : super( new EnclosedScope(enclosingScope)) { 4695 FunctionTypeScope(Scope enclosingScope, FunctionTypeAliasElement typeElement) : super(new EnclosedScope(enclosingScope)) {
4662 defineTypeParameters(typeElement); 4696 defineTypeParameters(typeElement);
4663 } 4697 }
4664 /** 4698 /**
4665 * Define the type parameters for the function type alias. 4699 * Define the type parameters for the function type alias.
4666 * @param typeElement the element representing the type represented by this sc ope 4700 * @param typeElement the element representing the type represented by this sc ope
4667 */ 4701 */
4668 void defineTypeParameters(TypeAliasElement typeElement) { 4702 void defineTypeParameters(FunctionTypeAliasElement typeElement) {
4669 Scope parameterScope = enclosingScope; 4703 Scope parameterScope = enclosingScope;
4670 for (TypeVariableElement parameter in typeElement.typeVariables) { 4704 for (TypeVariableElement parameter in typeElement.typeVariables) {
4671 parameterScope.define(parameter); 4705 parameterScope.define(parameter);
4672 } 4706 }
4673 } 4707 }
4674 } 4708 }
4675 /** 4709 /**
4676 * Instances of the class {@code LabelScope} represent a scope in which a single label is defined. 4710 * Instances of the class {@code LabelScope} represent a scope in which a single label is defined.
4677 * @coverage dart.engine.resolver 4711 * @coverage dart.engine.resolver
4678 */ 4712 */
(...skipping 18 matching lines...) Expand all
4697 * The label element returned for scopes that can be the target of an unlabele d {@code break} or{@code continue}. 4731 * The label element returned for scopes that can be the target of an unlabele d {@code break} or{@code continue}.
4698 */ 4732 */
4699 static SimpleIdentifier _EMPTY_LABEL_IDENTIFIER = new SimpleIdentifier.full(ne w sc.StringToken(sc.TokenType.IDENTIFIER, "", 0)); 4733 static SimpleIdentifier _EMPTY_LABEL_IDENTIFIER = new SimpleIdentifier.full(ne w sc.StringToken(sc.TokenType.IDENTIFIER, "", 0));
4700 /** 4734 /**
4701 * Initialize a newly created scope to represent the potential target of an un labeled{@code break} or {@code continue}. 4735 * Initialize a newly created scope to represent the potential target of an un labeled{@code break} or {@code continue}.
4702 * @param outerScope the label scope enclosing the new label scope 4736 * @param outerScope the label scope enclosing the new label scope
4703 * @param onSwitchStatement {@code true} if this label is associated with a {@ code switch}statement 4737 * @param onSwitchStatement {@code true} if this label is associated with a {@ code switch}statement
4704 * @param onSwitchMember {@code true} if this label is associated with a {@cod e switch} member 4738 * @param onSwitchMember {@code true} if this label is associated with a {@cod e switch} member
4705 */ 4739 */
4706 LabelScope.con1(LabelScope outerScope, bool onSwitchStatement, bool onSwitchMe mber) { 4740 LabelScope.con1(LabelScope outerScope, bool onSwitchStatement, bool onSwitchMe mber) {
4707 _jtd_constructor_237_impl(outerScope, onSwitchStatement, onSwitchMember); 4741 _jtd_constructor_248_impl(outerScope, onSwitchStatement, onSwitchMember);
4708 } 4742 }
4709 _jtd_constructor_237_impl(LabelScope outerScope, bool onSwitchStatement, bool onSwitchMember) { 4743 _jtd_constructor_248_impl(LabelScope outerScope, bool onSwitchStatement, bool onSwitchMember) {
4710 _jtd_constructor_238_impl(outerScope, EMPTY_LABEL, new LabelElementImpl(_EMP TY_LABEL_IDENTIFIER, onSwitchStatement, onSwitchMember)); 4744 _jtd_constructor_249_impl(outerScope, EMPTY_LABEL, new LabelElementImpl(_EMP TY_LABEL_IDENTIFIER, onSwitchStatement, onSwitchMember));
4711 } 4745 }
4712 /** 4746 /**
4713 * Initialize a newly created scope to represent the given label. 4747 * Initialize a newly created scope to represent the given label.
4714 * @param outerScope the label scope enclosing the new label scope 4748 * @param outerScope the label scope enclosing the new label scope
4715 * @param label the label defined in this scope 4749 * @param label the label defined in this scope
4716 * @param element the element to which the label resolves 4750 * @param element the element to which the label resolves
4717 */ 4751 */
4718 LabelScope.con2(LabelScope outerScope2, String label4, LabelElement element19) { 4752 LabelScope.con2(LabelScope outerScope2, String label4, LabelElement element19) {
4719 _jtd_constructor_238_impl(outerScope2, label4, element19); 4753 _jtd_constructor_249_impl(outerScope2, label4, element19);
4720 } 4754 }
4721 _jtd_constructor_238_impl(LabelScope outerScope2, String label4, LabelElement element19) { 4755 _jtd_constructor_249_impl(LabelScope outerScope2, String label4, LabelElement element19) {
4722 this._outerScope = outerScope2; 4756 this._outerScope = outerScope2;
4723 this._label = label4; 4757 this._label = label4;
4724 this._element = element19; 4758 this._element = element19;
4725 } 4759 }
4726 /** 4760 /**
4727 * Return the label element corresponding to the given label, or {@code null} if the given label 4761 * Return the label element corresponding to the given label, or {@code null} if the given label
4728 * is not defined in this scope. 4762 * is not defined in this scope.
4729 * @param targetLabel the label being looked up 4763 * @param targetLabel the label being looked up
4730 * @return the label element corresponding to the given label 4764 * @return the label element corresponding to the given label
4731 */ 4765 */
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
4841 * @param compilationUnit the compilation unit defining the top-level names to be added to this 4875 * @param compilationUnit the compilation unit defining the top-level names to be added to this
4842 * scope 4876 * scope
4843 */ 4877 */
4844 void defineLocalNames(CompilationUnitElement compilationUnit) { 4878 void defineLocalNames(CompilationUnitElement compilationUnit) {
4845 for (PropertyAccessorElement element in compilationUnit.accessors) { 4879 for (PropertyAccessorElement element in compilationUnit.accessors) {
4846 define(element); 4880 define(element);
4847 } 4881 }
4848 for (FunctionElement element in compilationUnit.functions) { 4882 for (FunctionElement element in compilationUnit.functions) {
4849 define(element); 4883 define(element);
4850 } 4884 }
4851 for (TypeAliasElement element in compilationUnit.typeAliases) { 4885 for (FunctionTypeAliasElement element in compilationUnit.functionTypeAliases ) {
4852 define(element); 4886 define(element);
4853 } 4887 }
4854 for (ClassElement element in compilationUnit.types) { 4888 for (ClassElement element in compilationUnit.types) {
4855 define(element); 4889 define(element);
4856 } 4890 }
4857 } 4891 }
4858 /** 4892 /**
4859 * Add to this scope all of the names that are explicitly defined in the given library. 4893 * Add to this scope all of the names that are explicitly defined in the given library.
4860 * @param definingLibrary the element representing the library that defines th e names in this 4894 * @param definingLibrary the element representing the library that defines th e names in this
4861 * scope 4895 * scope
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
4987 * @param compilationUnit the compilation unit defining the top-level names to be added to this 5021 * @param compilationUnit the compilation unit defining the top-level names to be added to this
4988 * namespace 5022 * namespace
4989 */ 5023 */
4990 void addPublicNames(Map<String, Element> definedNames, CompilationUnitElement compilationUnit) { 5024 void addPublicNames(Map<String, Element> definedNames, CompilationUnitElement compilationUnit) {
4991 for (PropertyAccessorElement element in compilationUnit.accessors) { 5025 for (PropertyAccessorElement element in compilationUnit.accessors) {
4992 addIfPublic(definedNames, element); 5026 addIfPublic(definedNames, element);
4993 } 5027 }
4994 for (FunctionElement element in compilationUnit.functions) { 5028 for (FunctionElement element in compilationUnit.functions) {
4995 addIfPublic(definedNames, element); 5029 addIfPublic(definedNames, element);
4996 } 5030 }
4997 for (TypeAliasElement element in compilationUnit.typeAliases) { 5031 for (FunctionTypeAliasElement element in compilationUnit.functionTypeAliases ) {
4998 addIfPublic(definedNames, element); 5032 addIfPublic(definedNames, element);
4999 } 5033 }
5000 for (ClassElement element in compilationUnit.types) { 5034 for (ClassElement element in compilationUnit.types) {
5001 addIfPublic(definedNames, element); 5035 addIfPublic(definedNames, element);
5002 } 5036 }
5003 for (VariableElement element in compilationUnit.topLevelVariables) { 5037 for (VariableElement element in compilationUnit.topLevelVariables) {
5004 addIfPublic(definedNames, element); 5038 addIfPublic(definedNames, element);
5005 } 5039 }
5006 } 5040 }
5007 /** 5041 /**
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
5226 * errors and warnings not covered by the parser and resolver. In particular, it looks for errors 5260 * errors and warnings not covered by the parser and resolver. In particular, it looks for errors
5227 * and warnings related to constant expressions. 5261 * and warnings related to constant expressions.
5228 * @coverage dart.engine.resolver 5262 * @coverage dart.engine.resolver
5229 */ 5263 */
5230 class ConstantVerifier extends RecursiveASTVisitor<Object> { 5264 class ConstantVerifier extends RecursiveASTVisitor<Object> {
5231 /** 5265 /**
5232 * The error reporter by which errors will be reported. 5266 * The error reporter by which errors will be reported.
5233 */ 5267 */
5234 ErrorReporter _errorReporter; 5268 ErrorReporter _errorReporter;
5235 /** 5269 /**
5236 * The constant evaluator used to evaluate constants.
5237 */
5238 ConstantEvaluator _evaluator;
5239 /**
5240 * Initialize a newly created constant verifier. 5270 * Initialize a newly created constant verifier.
5241 * @param errorReporter the error reporter by which errors will be reported 5271 * @param errorReporter the error reporter by which errors will be reported
5242 */ 5272 */
5243 ConstantVerifier(ErrorReporter errorReporter) { 5273 ConstantVerifier(ErrorReporter errorReporter) {
5244 this._errorReporter = errorReporter; 5274 this._errorReporter = errorReporter;
5245 _evaluator = new ConstantEvaluator(errorReporter);
5246 } 5275 }
5247 Object visitFunctionExpression(FunctionExpression node) { 5276 Object visitFunctionExpression(FunctionExpression node) {
5248 super.visitFunctionExpression(node); 5277 super.visitFunctionExpression(node);
5249 validateDefaultValues(node.parameters); 5278 validateDefaultValues(node.parameters);
5250 return null; 5279 return null;
5251 } 5280 }
5252 Object visitListLiteral(ListLiteral node) { 5281 Object visitListLiteral(ListLiteral node) {
5253 super.visitListLiteral(node); 5282 super.visitListLiteral(node);
5254 if (node.modifier != null) { 5283 if (node.modifier != null) {
5255 for (Expression element in node.elements) { 5284 for (Expression element in node.elements) {
5256 validate(element, CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT); 5285 validate(element, CompileTimeErrorCode.NON_CONSTANT_LIST_ELEMENT);
5257 } 5286 }
5258 } 5287 }
5259 return null; 5288 return null;
5260 } 5289 }
5261 Object visitMapLiteral(MapLiteral node) { 5290 Object visitMapLiteral(MapLiteral node) {
5262 super.visitMapLiteral(node); 5291 super.visitMapLiteral(node);
5263 bool isConst = node.modifier != null; 5292 bool isConst = node.modifier != null;
5264 Set<String> keys = new Set<String>(); 5293 Set<String> keys = new Set<String>();
5265 for (MapLiteralEntry entry in node.entries) { 5294 for (MapLiteralEntry entry in node.entries) {
5266 StringLiteral key4 = entry.key; 5295 StringLiteral key4 = entry.key;
5267 Object value = validate(key4, CompileTimeErrorCode.NON_CONSTANT_MAP_KEY); 5296 EvaluationResultImpl result = validate(key4, CompileTimeErrorCode.NON_CONS TANT_MAP_KEY);
5268 if (value is String) { 5297 if (result is ValidResult && ((result as ValidResult)).value is String) {
5269 if (keys.contains(value)) { 5298 String value10 = ((result as ValidResult)).value as String;
5299 if (keys.contains(value10)) {
5270 _errorReporter.reportError(StaticWarningCode.EQUAL_KEYS_IN_MAP, key4, []); 5300 _errorReporter.reportError(StaticWarningCode.EQUAL_KEYS_IN_MAP, key4, []);
5271 } else { 5301 } else {
5272 javaSetAdd(keys, (value as String)); 5302 javaSetAdd(keys, value10);
5273 } 5303 }
5274 } else if (value != null) {
5275 } 5304 }
5276 if (isConst) { 5305 if (isConst) {
5277 validate(entry.value, CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE); 5306 validate(entry.value, CompileTimeErrorCode.NON_CONSTANT_MAP_VALUE);
5278 } 5307 }
5279 } 5308 }
5280 return null; 5309 return null;
5281 } 5310 }
5282 Object visitMethodDeclaration(MethodDeclaration node) { 5311 Object visitMethodDeclaration(MethodDeclaration node) {
5283 super.visitMethodDeclaration(node); 5312 super.visitMethodDeclaration(node);
5284 validateDefaultValues(node.parameters); 5313 validateDefaultValues(node.parameters);
5285 return null; 5314 return null;
5286 } 5315 }
5287 Object visitSwitchCase(SwitchCase node) { 5316 Object visitSwitchCase(SwitchCase node) {
5288 super.visitSwitchCase(node); 5317 super.visitSwitchCase(node);
5289 validate(node.expression, CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION) ; 5318 validate(node.expression, CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION) ;
5290 return null; 5319 return null;
5291 } 5320 }
5292 Object visitVariableDeclaration(VariableDeclaration node) { 5321 Object visitVariableDeclaration(VariableDeclaration node) {
5293 super.visitVariableDeclaration(node); 5322 super.visitVariableDeclaration(node);
5294 Expression initializer4 = node.initializer; 5323 Expression initializer4 = node.initializer;
5295 if (initializer4 != null && node.isConst()) { 5324 if (initializer4 != null && node.isConst()) {
5296 validate(initializer4, CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CON STANT_VALUE); 5325 EvaluationResultImpl result = validate(initializer4, CompileTimeErrorCode. CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE);
5326 VariableElementImpl element45 = node.element as VariableElementImpl;
5327 element45.evaluationResult = result;
5297 } 5328 }
5298 return null; 5329 return null;
5299 } 5330 }
5300 /** 5331 /**
5301 * Validate that the given expression is a compile time constant. Return the v alue of the compile 5332 * Validate that the given expression is a compile time constant. Return the v alue of the compile
5302 * time constant, or {@code null} if the expression is not a compile time cons tant. 5333 * time constant, or {@code null} if the expression is not a compile time cons tant.
5303 * @param expression the expression to be validated 5334 * @param expression the expression to be validated
5304 * @param errorCode the error code to be used if the expression is not a compi le time constant 5335 * @param errorCode the error code to be used if the expression is not a compi le time constant
5305 * @return the value of the compile time constant 5336 * @return the value of the compile time constant
5306 */ 5337 */
5307 Object validate(Expression expression, ErrorCode errorCode) { 5338 EvaluationResultImpl validate(Expression expression, ErrorCode errorCode4) {
5308 Object value = expression.accept(_evaluator); 5339 EvaluationResultImpl result = expression.accept(new ConstantVisitor());
5309 if (identical(value, ConstantEvaluator.NOT_A_CONSTANT)) { 5340 if (result is ErrorResult) {
5310 _errorReporter.reportError(errorCode, expression, []); 5341 for (ErrorResult_ErrorData data in ((result as ErrorResult)).errorData) {
5311 return null; 5342 if (identical(data.errorCode, CompileTimeErrorCode.COMPILE_TIME_CONSTANT _RAISES_EXCEPTION_DIVIDE_BY_ZERO)) {
5343 _errorReporter.reportError(data.errorCode, data.node, []);
5344 } else {
5345 _errorReporter.reportError(errorCode4, data.node, []);
5346 }
5347 }
5312 } 5348 }
5313 if (identical(value, errorCode)) { 5349 return result;
5314 _errorReporter.reportError(CompileTimeErrorCode.COMPILE_TIME_CONSTANT_RAIS ES_EXCEPTION, expression, []);
5315 return null;
5316 }
5317 if (identical(value, errorCode)) {
5318 _errorReporter.reportError(CompileTimeErrorCode.RECURSIVE_COMPILE_TIME_CON STANT, expression, []);
5319 return null;
5320 }
5321 return value;
5322 } 5350 }
5323 /** 5351 /**
5324 * Validate that the default value associated with each of the parameters in t he given list is a 5352 * Validate that the default value associated with each of the parameters in t he given list is a
5325 * compile time constant. 5353 * compile time constant.
5326 * @param parameters the list of parameters to be validated 5354 * @param parameters the list of parameters to be validated
5327 */ 5355 */
5328 void validateDefaultValues(FormalParameterList parameters14) { 5356 void validateDefaultValues(FormalParameterList parameters14) {
5329 if (parameters14 == null) { 5357 if (parameters14 == null) {
5330 return; 5358 return;
5331 } 5359 }
5332 for (FormalParameter parameter in parameters14.parameters) { 5360 for (FormalParameter parameter in parameters14.parameters) {
5333 if (parameter is DefaultFormalParameter) { 5361 if (parameter is DefaultFormalParameter) {
5334 Expression defaultValue2 = ((parameter as DefaultFormalParameter)).defau ltValue; 5362 DefaultFormalParameter defaultParameter = parameter as DefaultFormalPara meter;
5363 Expression defaultValue2 = defaultParameter.defaultValue;
5335 if (defaultValue2 != null) { 5364 if (defaultValue2 != null) {
5336 validate(defaultValue2, CompileTimeErrorCode.NON_CONSTANT_DEFAULT_VALU E); 5365 EvaluationResultImpl result = validate(defaultValue2, CompileTimeError Code.NON_CONSTANT_DEFAULT_VALUE);
5366 if (defaultParameter.isConst()) {
5367 VariableElementImpl element46 = parameter.element as VariableElement Impl;
5368 element46.evaluationResult = result;
5369 }
5337 } 5370 }
5338 } 5371 }
5339 } 5372 }
5340 } 5373 }
5341 } 5374 }
5342 /** 5375 /**
5343 * Instances of the class {@code ErrorVerifier} traverse an AST structure lookin g for additional 5376 * Instances of the class {@code ErrorVerifier} traverse an AST structure lookin g for additional
5344 * errors and warnings not covered by the parser and resolver. 5377 * errors and warnings not covered by the parser and resolver.
5345 * @coverage dart.engine.resolver 5378 * @coverage dart.engine.resolver
5346 */ 5379 */
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
5440 Object visitIfStatement(IfStatement node) { 5473 Object visitIfStatement(IfStatement node) {
5441 checkForNonBoolCondition(node.condition); 5474 checkForNonBoolCondition(node.condition);
5442 return super.visitIfStatement(node); 5475 return super.visitIfStatement(node);
5443 } 5476 }
5444 Object visitInstanceCreationExpression(InstanceCreationExpression node) { 5477 Object visitInstanceCreationExpression(InstanceCreationExpression node) {
5445 ConstructorName constructorName4 = node.constructorName; 5478 ConstructorName constructorName4 = node.constructorName;
5446 TypeName typeName = constructorName4.type; 5479 TypeName typeName = constructorName4.type;
5447 Type2 type20 = typeName.type; 5480 Type2 type20 = typeName.type;
5448 if (type20 is InterfaceType) { 5481 if (type20 is InterfaceType) {
5449 InterfaceType interfaceType = type20 as InterfaceType; 5482 InterfaceType interfaceType = type20 as InterfaceType;
5483 checkForConstWithNonConst(node);
5450 checkForConstOrNewWithAbstractClass(node, typeName, interfaceType); 5484 checkForConstOrNewWithAbstractClass(node, typeName, interfaceType);
5451 checkForTypeArgumentNotMatchingBounds(node, constructorName4.element, type Name); 5485 checkForTypeArgumentNotMatchingBounds(node, constructorName4.element, type Name);
5452 } else {
5453 _errorReporter.reportError(CompileTimeErrorCode.NON_CONSTANT_MAP_KEY, type Name, []);
5454 } 5486 }
5455 return super.visitInstanceCreationExpression(node); 5487 return super.visitInstanceCreationExpression(node);
5456 } 5488 }
5457 Object visitMethodDeclaration(MethodDeclaration node) { 5489 Object visitMethodDeclaration(MethodDeclaration node) {
5458 ExecutableElement previousFunction = _currentFunction; 5490 ExecutableElement previousFunction = _currentFunction;
5459 try { 5491 try {
5460 _currentFunction = node.element; 5492 _currentFunction = node.element;
5461 return super.visitMethodDeclaration(node); 5493 return super.visitMethodDeclaration(node);
5462 } finally { 5494 } finally {
5463 _currentFunction = previousFunction; 5495 _currentFunction = previousFunction;
(...skipping 24 matching lines...) Expand all
5488 return super.visitWhileStatement(node); 5520 return super.visitWhileStatement(node);
5489 } 5521 }
5490 /** 5522 /**
5491 * This verifies that the passed argument definition test identifier is a para meter. 5523 * This verifies that the passed argument definition test identifier is a para meter.
5492 * @param node the {@link ArgumentDefinitionTest} to evaluate 5524 * @param node the {@link ArgumentDefinitionTest} to evaluate
5493 * @return return <code>true</code> if and only if an error code is generated on the passed node 5525 * @return return <code>true</code> if and only if an error code is generated on the passed node
5494 * @see CompileTimeErrorCode#ARGUMENT_DEFINITION_TEST_NON_PARAMETER 5526 * @see CompileTimeErrorCode#ARGUMENT_DEFINITION_TEST_NON_PARAMETER
5495 */ 5527 */
5496 bool checkForArgumentDefinitionTestNonParameter(ArgumentDefinitionTest node) { 5528 bool checkForArgumentDefinitionTestNonParameter(ArgumentDefinitionTest node) {
5497 SimpleIdentifier identifier14 = node.identifier; 5529 SimpleIdentifier identifier14 = node.identifier;
5498 Element element44 = identifier14.element; 5530 Element element47 = identifier14.element;
5499 if (element44 != null && element44 is! ParameterElement) { 5531 if (element47 != null && element47 is! ParameterElement) {
5500 _errorReporter.reportError(CompileTimeErrorCode.ARGUMENT_DEFINITION_TEST_N ON_PARAMETER, identifier14, [identifier14.name]); 5532 _errorReporter.reportError(CompileTimeErrorCode.ARGUMENT_DEFINITION_TEST_N ON_PARAMETER, identifier14, [identifier14.name]);
5501 return true; 5533 return true;
5502 } 5534 }
5503 return false; 5535 return false;
5504 } 5536 }
5505 /** 5537 /**
5506 * This verifies that the passed identifier is not a keyword, and generates th e passed error code 5538 * This verifies that the passed identifier is not a keyword, and generates th e passed error code
5507 * on the identifier if it is a keyword. 5539 * on the identifier if it is a keyword.
5508 * @param identifier the identifier to check to ensure that it is not a keywor d 5540 * @param identifier the identifier to check to ensure that it is not a keywor d
5509 * @param errorCode if the passed identifier is a keyword then this error code is created on the 5541 * @param errorCode if the passed identifier is a keyword then this error code is created on the
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
5548 * This verifies that the passed switch statement does not have a case express ion with the 5580 * This verifies that the passed switch statement does not have a case express ion with the
5549 * operator '==' overridden. 5581 * operator '==' overridden.
5550 * @param node the switch statement to evaluate 5582 * @param node the switch statement to evaluate
5551 * @return return <code>true</code> if and only if an error code is generated on the passed node 5583 * @return return <code>true</code> if and only if an error code is generated on the passed node
5552 * @see CompileTimeErrorCode#CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS 5584 * @see CompileTimeErrorCode#CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS
5553 */ 5585 */
5554 bool checkForCaseExpressionTypeImplementsEquals(SwitchStatement node) { 5586 bool checkForCaseExpressionTypeImplementsEquals(SwitchStatement node) {
5555 Expression expression16 = node.expression; 5587 Expression expression16 = node.expression;
5556 Type2 type = expression16.staticType; 5588 Type2 type = expression16.staticType;
5557 if (type != null && type != _typeProvider.intType && type != _typeProvider.s tringType) { 5589 if (type != null && type != _typeProvider.intType && type != _typeProvider.s tringType) {
5558 Element element45 = type.element; 5590 Element element48 = type.element;
5559 if (element45 is ClassElement) { 5591 if (element48 is ClassElement) {
5560 ClassElement classElement = element45 as ClassElement; 5592 ClassElement classElement = element48 as ClassElement;
5561 MethodElement method = classElement.lookUpMethod("==", _currentLibrary); 5593 MethodElement method = classElement.lookUpMethod("==", _currentLibrary);
5562 if (method != null && method.enclosingElement.type != _typeProvider.obje ctType) { 5594 if (method != null && method.enclosingElement.type != _typeProvider.obje ctType) {
5563 _errorReporter.reportError(CompileTimeErrorCode.CASE_EXPRESSION_TYPE_I MPLEMENTS_EQUALS, expression16, [element45.name]); 5595 _errorReporter.reportError(CompileTimeErrorCode.CASE_EXPRESSION_TYPE_I MPLEMENTS_EQUALS, expression16, [element48.name]);
5564 return true; 5596 return true;
5565 } 5597 }
5566 } 5598 }
5567 } 5599 }
5568 return false; 5600 return false;
5569 } 5601 }
5570 bool checkForConflictingConstructorNameAndMember(ConstructorDeclaration node) { 5602 bool checkForConflictingConstructorNameAndMember(ConstructorDeclaration node) {
5571 ConstructorElement constructorElement = node.element; 5603 ConstructorElement constructorElement = node.element;
5572 SimpleIdentifier constructorName = node.name; 5604 SimpleIdentifier constructorName = node.name;
5573 if (constructorName != null && constructorElement != null && !constructorNam e.isSynthetic()) { 5605 if (constructorName != null && constructorElement != null && !constructorNam e.isSynthetic()) {
(...skipping 25 matching lines...) Expand all
5599 */ 5631 */
5600 bool checkForConstConstructorWithNonFinalField(ConstructorDeclaration node) { 5632 bool checkForConstConstructorWithNonFinalField(ConstructorDeclaration node) {
5601 if (node.constKeyword == null) { 5633 if (node.constKeyword == null) {
5602 return false; 5634 return false;
5603 } 5635 }
5604 ConstructorElement constructorElement = node.element; 5636 ConstructorElement constructorElement = node.element;
5605 if (constructorElement != null) { 5637 if (constructorElement != null) {
5606 ClassElement classElement = constructorElement.enclosingElement; 5638 ClassElement classElement = constructorElement.enclosingElement;
5607 List<FieldElement> elements = classElement.fields; 5639 List<FieldElement> elements = classElement.fields;
5608 for (FieldElement field in elements) { 5640 for (FieldElement field in elements) {
5609 if (!field.isFinal() && !field.isConst()) { 5641 if (!field.isFinal() && !field.isConst() && !field.isSynthetic()) {
5610 _errorReporter.reportError(CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH _NON_FINAL_FIELD, node, []); 5642 _errorReporter.reportError(CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH _NON_FINAL_FIELD, node, []);
5611 return true; 5643 return true;
5612 } 5644 }
5613 } 5645 }
5614 } 5646 }
5615 return false; 5647 return false;
5616 } 5648 }
5617 /** 5649 /**
5618 * This verifies that the passed normal formal parameter is not 'const'. 5650 * This verifies that the passed normal formal parameter is not 'const'.
5619 * @param node the normal formal parameter to evaluate 5651 * @param node the normal formal parameter to evaluate
(...skipping 12 matching lines...) Expand all
5632 * class. 5664 * class.
5633 * @param node the instance creation expression to evaluate 5665 * @param node the instance creation expression to evaluate
5634 * @param typeName the {@link TypeName} of the {@link ConstructorName} from th e{@link InstanceCreationExpression}, this is the AST node that the error is atta ched to 5666 * @param typeName the {@link TypeName} of the {@link ConstructorName} from th e{@link InstanceCreationExpression}, this is the AST node that the error is atta ched to
5635 * @param type the type being constructed with this {@link InstanceCreationExp ression} 5667 * @param type the type being constructed with this {@link InstanceCreationExp ression}
5636 * @return return <code>true</code> if and only if an error code is generated on the passed node 5668 * @return return <code>true</code> if and only if an error code is generated on the passed node
5637 * @see StaticWarningCode#CONST_WITH_ABSTRACT_CLASS 5669 * @see StaticWarningCode#CONST_WITH_ABSTRACT_CLASS
5638 * @see StaticWarningCode#NEW_WITH_ABSTRACT_CLASS 5670 * @see StaticWarningCode#NEW_WITH_ABSTRACT_CLASS
5639 */ 5671 */
5640 bool checkForConstOrNewWithAbstractClass(InstanceCreationExpression node, Type Name typeName, InterfaceType type) { 5672 bool checkForConstOrNewWithAbstractClass(InstanceCreationExpression node, Type Name typeName, InterfaceType type) {
5641 if (type.element.isAbstract()) { 5673 if (type.element.isAbstract()) {
5642 ConstructorElement element46 = node.element; 5674 ConstructorElement element49 = node.element;
5643 if (element46 != null && !element46.isFactory()) { 5675 if (element49 != null && !element49.isFactory()) {
5644 if (identical(((node.keyword as sc.KeywordToken)).keyword, sc.Keyword.CO NST)) { 5676 if (identical(((node.keyword as sc.KeywordToken)).keyword, sc.Keyword.CO NST)) {
5645 _errorReporter.reportError(StaticWarningCode.CONST_WITH_ABSTRACT_CLASS , typeName, []); 5677 _errorReporter.reportError(StaticWarningCode.CONST_WITH_ABSTRACT_CLASS , typeName, []);
5646 } else { 5678 } else {
5647 _errorReporter.reportError(StaticWarningCode.NEW_WITH_ABSTRACT_CLASS, typeName, []); 5679 _errorReporter.reportError(StaticWarningCode.NEW_WITH_ABSTRACT_CLASS, typeName, []);
5648 } 5680 }
5649 return true; 5681 return true;
5650 } 5682 }
5651 } 5683 }
5652 return false; 5684 return false;
5653 } 5685 }
5654 /** 5686 /**
5687 * This verifies that if the passed instance creation expression is 'const', t hen it is not being
5688 * invoked on a constructor that is not 'const'.
5689 * @param node the instance creation expression to evaluate
5690 * @return return <code>true</code> if and only if an error code is generated on the passed node
5691 * @see CompileTimeErrorCode#CONST_WITH_NON_CONST
5692 */
5693 bool checkForConstWithNonConst(InstanceCreationExpression node) {
5694 if (node.isConst() && !node.element.isConst()) {
5695 _errorReporter.reportError(CompileTimeErrorCode.CONST_WITH_NON_CONST, node , []);
5696 return true;
5697 }
5698 return false;
5699 }
5700 /**
5655 * This verifies that the passed assignment expression represents a valid assi gnment. 5701 * This verifies that the passed assignment expression represents a valid assi gnment.
5656 * @param node the assignment expression to evaluate 5702 * @param node the assignment expression to evaluate
5657 * @return return <code>true</code> if and only if an error code is generated on the passed node 5703 * @return return <code>true</code> if and only if an error code is generated on the passed node
5658 * @see StaticTypeWarningCode#INVALID_ASSIGNMENT 5704 * @see StaticTypeWarningCode#INVALID_ASSIGNMENT
5659 */ 5705 */
5660 bool checkForInvalidAssignment(AssignmentExpression node) { 5706 bool checkForInvalidAssignment(AssignmentExpression node) {
5661 Expression lhs = node.leftHandSide; 5707 Expression lhs = node.leftHandSide;
5662 Expression rhs = node.rightHandSide; 5708 Expression rhs = node.rightHandSide;
5663 Type2 leftType = getType(lhs); 5709 Type2 leftType = getType(lhs);
5664 Type2 rightType = getType(rhs); 5710 Type2 rightType = getType(rhs);
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
5798 ResolverErrorCode(this.__name, this.__ordinal, ErrorType type, String message) { 5844 ResolverErrorCode(this.__name, this.__ordinal, ErrorType type, String message) {
5799 this._type = type; 5845 this._type = type;
5800 this._message = message; 5846 this._message = message;
5801 } 5847 }
5802 ErrorSeverity get errorSeverity => _type.severity; 5848 ErrorSeverity get errorSeverity => _type.severity;
5803 String get message => _message; 5849 String get message => _message;
5804 ErrorType get type => _type; 5850 ErrorType get type => _type;
5805 bool needsRecompilation() => true; 5851 bool needsRecompilation() => true;
5806 String toString() => __name; 5852 String toString() => __name;
5807 } 5853 }
OLDNEW
« no previous file with comments | « pkg/analyzer_experimental/lib/src/generated/parser.dart ('k') | pkg/analyzer_experimental/lib/src/generated/scanner.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698