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

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

Issue 17317002: Convert isX() methods to isX getter. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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 library engine.resolver; 3 library engine.resolver;
4 import 'dart:collection'; 4 import 'dart:collection';
5 import 'java_core.dart'; 5 import 'java_core.dart';
6 import 'java_engine.dart'; 6 import 'java_engine.dart';
7 import 'instrumentation.dart'; 7 import 'instrumentation.dart';
8 import 'source.dart'; 8 import 'source.dart';
9 import 'error.dart'; 9 import 'error.dart';
10 import 'scanner.dart' as sc; 10 import 'scanner.dart' as sc;
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 initializer.labels = holder.labels; 225 initializer.labels = holder.labels;
226 initializer.localVariables = holder.localVariables; 226 initializer.localVariables = holder.localVariables;
227 initializer.parameters = holder.parameters; 227 initializer.parameters = holder.parameters;
228 SimpleIdentifier parameterName = node.parameter.identifier; 228 SimpleIdentifier parameterName = node.parameter.identifier;
229 ParameterElementImpl parameter; 229 ParameterElementImpl parameter;
230 if (node.parameter is FieldFormalParameter) { 230 if (node.parameter is FieldFormalParameter) {
231 parameter = new DefaultFieldFormalParameterElementImpl(parameterName); 231 parameter = new DefaultFieldFormalParameterElementImpl(parameterName);
232 } else { 232 } else {
233 parameter = new DefaultParameterElementImpl(parameterName); 233 parameter = new DefaultParameterElementImpl(parameterName);
234 } 234 }
235 parameter.const3 = node.isConst(); 235 parameter.const3 = node.isConst;
236 parameter.final2 = node.isFinal(); 236 parameter.final2 = node.isFinal;
237 parameter.initializer = initializer; 237 parameter.initializer = initializer;
238 parameter.parameterKind = node.kind; 238 parameter.parameterKind = node.kind;
239 Expression defaultValue = node.defaultValue; 239 Expression defaultValue = node.defaultValue;
240 if (defaultValue != null) { 240 if (defaultValue != null) {
241 parameter.setDefaultValueRange(defaultValue.offset, defaultValue.length); 241 parameter.setDefaultValueRange(defaultValue.offset, defaultValue.length);
242 } 242 }
243 FunctionBody body = getFunctionBody(node); 243 FunctionBody body = getFunctionBody(node);
244 if (body != null) { 244 if (body != null) {
245 parameter.setVisibleRange(body.offset, body.length); 245 parameter.setVisibleRange(body.offset, body.length);
246 } 246 }
(...skipping 10 matching lines...) Expand all
257 node.visitChildren(this); 257 node.visitChildren(this);
258 } finally { 258 } finally {
259 _inFieldContext = wasInField; 259 _inFieldContext = wasInField;
260 } 260 }
261 return null; 261 return null;
262 } 262 }
263 Object visitFieldFormalParameter(FieldFormalParameter node) { 263 Object visitFieldFormalParameter(FieldFormalParameter node) {
264 if (node.parent is! DefaultFormalParameter) { 264 if (node.parent is! DefaultFormalParameter) {
265 SimpleIdentifier parameterName = node.identifier; 265 SimpleIdentifier parameterName = node.identifier;
266 FieldFormalParameterElementImpl parameter = new FieldFormalParameterElemen tImpl(parameterName); 266 FieldFormalParameterElementImpl parameter = new FieldFormalParameterElemen tImpl(parameterName);
267 parameter.const3 = node.isConst(); 267 parameter.const3 = node.isConst;
268 parameter.final2 = node.isFinal(); 268 parameter.final2 = node.isFinal;
269 parameter.parameterKind = node.kind; 269 parameter.parameterKind = node.kind;
270 _currentHolder.addParameter(parameter); 270 _currentHolder.addParameter(parameter);
271 parameterName.element = parameter; 271 parameterName.element = parameter;
272 } 272 }
273 return super.visitFieldFormalParameter(node); 273 return super.visitFieldFormalParameter(node);
274 } 274 }
275 Object visitFunctionDeclaration(FunctionDeclaration node) { 275 Object visitFunctionDeclaration(FunctionDeclaration node) {
276 FunctionExpression expression = node.functionExpression; 276 FunctionExpression expression = node.functionExpression;
277 if (expression != null) { 277 if (expression != null) {
278 ElementHolder holder = new ElementHolder(); 278 ElementHolder holder = new ElementHolder();
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 } 412 }
413 Object visitMethodDeclaration(MethodDeclaration node) { 413 Object visitMethodDeclaration(MethodDeclaration node) {
414 ElementHolder holder = new ElementHolder(); 414 ElementHolder holder = new ElementHolder();
415 bool wasInFunction = _inFunction; 415 bool wasInFunction = _inFunction;
416 _inFunction = true; 416 _inFunction = true;
417 try { 417 try {
418 visitChildren(holder, node); 418 visitChildren(holder, node);
419 } finally { 419 } finally {
420 _inFunction = wasInFunction; 420 _inFunction = wasInFunction;
421 } 421 }
422 bool isStatic = node.isStatic(); 422 bool isStatic = node.isStatic;
423 sc.Token property = node.propertyKeyword; 423 sc.Token property = node.propertyKeyword;
424 if (property == null) { 424 if (property == null) {
425 SimpleIdentifier methodName = node.name; 425 SimpleIdentifier methodName = node.name;
426 String nameOfMethod = methodName.name; 426 String nameOfMethod = methodName.name;
427 if (nameOfMethod == sc.TokenType.MINUS.lexeme && node.parameters.parameter s.length == 0) { 427 if (nameOfMethod == sc.TokenType.MINUS.lexeme && node.parameters.parameter s.length == 0) {
428 nameOfMethod = "unary-"; 428 nameOfMethod = "unary-";
429 } 429 }
430 MethodElementImpl element = new MethodElementImpl.con2(nameOfMethod, metho dName.offset); 430 MethodElementImpl element = new MethodElementImpl.con2(nameOfMethod, metho dName.offset);
431 element.abstract = node.isAbstract(); 431 element.abstract = node.isAbstract;
432 element.functions = holder.functions; 432 element.functions = holder.functions;
433 element.labels = holder.labels; 433 element.labels = holder.labels;
434 element.localVariables = holder.localVariables; 434 element.localVariables = holder.localVariables;
435 element.parameters = holder.parameters; 435 element.parameters = holder.parameters;
436 element.static = isStatic; 436 element.static = isStatic;
437 _currentHolder.addMethod(element); 437 _currentHolder.addMethod(element);
438 methodName.element = element; 438 methodName.element = element;
439 } else { 439 } else {
440 SimpleIdentifier propertyNameNode = node.name; 440 SimpleIdentifier propertyNameNode = node.name;
441 String propertyName = propertyNameNode.name; 441 String propertyName = propertyNameNode.name;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 propertyNameNode.element = setter; 474 propertyNameNode.element = setter;
475 } 475 }
476 } 476 }
477 holder.validate(); 477 holder.validate();
478 return null; 478 return null;
479 } 479 }
480 Object visitSimpleFormalParameter(SimpleFormalParameter node) { 480 Object visitSimpleFormalParameter(SimpleFormalParameter node) {
481 if (node.parent is! DefaultFormalParameter) { 481 if (node.parent is! DefaultFormalParameter) {
482 SimpleIdentifier parameterName = node.identifier; 482 SimpleIdentifier parameterName = node.identifier;
483 ParameterElementImpl parameter = new ParameterElementImpl(parameterName); 483 ParameterElementImpl parameter = new ParameterElementImpl(parameterName);
484 parameter.const3 = node.isConst(); 484 parameter.const3 = node.isConst;
485 parameter.final2 = node.isFinal(); 485 parameter.final2 = node.isFinal;
486 parameter.parameterKind = node.kind; 486 parameter.parameterKind = node.kind;
487 _currentHolder.addParameter(parameter); 487 _currentHolder.addParameter(parameter);
488 parameterName.element = parameter; 488 parameterName.element = parameter;
489 } 489 }
490 return super.visitSimpleFormalParameter(node); 490 return super.visitSimpleFormalParameter(node);
491 } 491 }
492 Object visitSuperExpression(SuperExpression node) { 492 Object visitSuperExpression(SuperExpression node) {
493 _isValidMixin = false; 493 _isValidMixin = false;
494 return super.visitSuperExpression(node); 494 return super.visitSuperExpression(node);
495 } 495 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 element.initializer = initializer; 583 element.initializer = initializer;
584 holder.validate(); 584 holder.validate();
585 } 585 }
586 if (element is PropertyInducingElementImpl) { 586 if (element is PropertyInducingElementImpl) {
587 PropertyInducingElementImpl variable = element as PropertyInducingElementI mpl; 587 PropertyInducingElementImpl variable = element as PropertyInducingElementI mpl;
588 if (_inFieldContext) { 588 if (_inFieldContext) {
589 ((variable as FieldElementImpl)).static = matches(((node.parent.parent a s FieldDeclaration)).keyword, sc.Keyword.STATIC); 589 ((variable as FieldElementImpl)).static = matches(((node.parent.parent a s FieldDeclaration)).keyword, sc.Keyword.STATIC);
590 } 590 }
591 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl.con2( variable); 591 PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl.con2( variable);
592 getter.getter = true; 592 getter.getter = true;
593 getter.static = variable.isStatic(); 593 getter.static = variable.isStatic;
594 _currentHolder.addAccessor(getter); 594 _currentHolder.addAccessor(getter);
595 variable.getter = getter; 595 variable.getter = getter;
596 if (!isFinal) { 596 if (!isFinal) {
597 PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl.con 2(variable); 597 PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl.con 2(variable);
598 setter.setter = true; 598 setter.setter = true;
599 setter.static = variable.isStatic(); 599 setter.static = variable.isStatic;
600 _currentHolder.addAccessor(setter); 600 _currentHolder.addAccessor(setter);
601 variable.setter = setter; 601 variable.setter = setter;
602 } 602 }
603 } 603 }
604 return null; 604 return null;
605 } 605 }
606 606
607 /** 607 /**
608 * Creates the [ConstructorElement]s array with the single default constructor element. 608 * Creates the [ConstructorElement]s array with the single default constructor element.
609 * @param interfaceType the interface type for which to create a default const ructor 609 * @param interfaceType the interface type for which to create a default const ructor
(...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after
1789 } 1789 }
1790 if (n is ConstructorDeclaration) { 1790 if (n is ConstructorDeclaration) {
1791 ConstructorDeclaration constructor = n as ConstructorDeclaration; 1791 ConstructorDeclaration constructor = n as ConstructorDeclaration;
1792 return constructor.factoryKeyword == null; 1792 return constructor.factoryKeyword == null;
1793 } 1793 }
1794 if (n is ConstructorFieldInitializer) { 1794 if (n is ConstructorFieldInitializer) {
1795 return false; 1795 return false;
1796 } 1796 }
1797 if (n is MethodDeclaration) { 1797 if (n is MethodDeclaration) {
1798 MethodDeclaration method = n as MethodDeclaration; 1798 MethodDeclaration method = n as MethodDeclaration;
1799 return !method.isStatic(); 1799 return !method.isStatic;
1800 } 1800 }
1801 } 1801 }
1802 return false; 1802 return false;
1803 } 1803 }
1804 1804
1805 /** 1805 /**
1806 * The resolver driving this participant. 1806 * The resolver driving this participant.
1807 */ 1807 */
1808 ResolverVisitor _resolver; 1808 ResolverVisitor _resolver;
1809 1809
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1849 node.element = select3(staticMethod, propagatedMethod); 1849 node.element = select3(staticMethod, propagatedMethod);
1850 if (shouldReportMissingMember(staticType, staticMethod) && (_strictMode || propagatedType == null || shouldReportMissingMember(propagatedType, propagate dMethod))) { 1850 if (shouldReportMissingMember(staticType, staticMethod) && (_strictMode || propagatedType == null || shouldReportMissingMember(propagatedType, propagate dMethod))) {
1851 _resolver.reportError6(StaticTypeWarningCode.UNDEFINED_METHOD, operato r, [methodName, staticType.displayName]); 1851 _resolver.reportError6(StaticTypeWarningCode.UNDEFINED_METHOD, operato r, [methodName, staticType.displayName]);
1852 } 1852 }
1853 } 1853 }
1854 } 1854 }
1855 return null; 1855 return null;
1856 } 1856 }
1857 Object visitBinaryExpression(BinaryExpression node) { 1857 Object visitBinaryExpression(BinaryExpression node) {
1858 sc.Token operator = node.operator; 1858 sc.Token operator = node.operator;
1859 if (operator.isUserDefinableOperator()) { 1859 if (operator.isUserDefinableOperator) {
1860 Expression leftOperand = node.leftOperand; 1860 Expression leftOperand = node.leftOperand;
1861 if (leftOperand != null) { 1861 if (leftOperand != null) {
1862 String methodName = operator.lexeme; 1862 String methodName = operator.lexeme;
1863 Type2 staticType = getStaticType(leftOperand); 1863 Type2 staticType = getStaticType(leftOperand);
1864 MethodElement staticMethod = lookUpMethod(leftOperand, staticType, metho dName); 1864 MethodElement staticMethod = lookUpMethod(leftOperand, staticType, metho dName);
1865 node.staticElement = staticMethod; 1865 node.staticElement = staticMethod;
1866 Type2 propagatedType = getPropagatedType(leftOperand); 1866 Type2 propagatedType = getPropagatedType(leftOperand);
1867 MethodElement propagatedMethod = lookUpMethod(leftOperand, propagatedTyp e, methodName); 1867 MethodElement propagatedMethod = lookUpMethod(leftOperand, propagatedTyp e, methodName);
1868 node.element = select3(staticMethod, propagatedMethod); 1868 node.element = select3(staticMethod, propagatedMethod);
1869 if (shouldReportMissingMember(staticType, staticMethod) && (_strictMode || propagatedType == null || shouldReportMissingMember(propagatedType, propagate dMethod))) { 1869 if (shouldReportMissingMember(staticType, staticMethod) && (_strictMode || propagatedType == null || shouldReportMissingMember(propagatedType, propagate dMethod))) {
1870 _resolver.reportError6(StaticTypeWarningCode.UNDEFINED_OPERATOR, opera tor, [methodName, staticType.displayName]); 1870 _resolver.reportError6(StaticTypeWarningCode.UNDEFINED_OPERATOR, opera tor, [methodName, staticType.displayName]);
1871 } 1871 }
1872 } 1872 }
1873 } 1873 }
1874 return null; 1874 return null;
1875 } 1875 }
1876 Object visitBreakStatement(BreakStatement node) { 1876 Object visitBreakStatement(BreakStatement node) {
1877 SimpleIdentifier labelNode = node.label; 1877 SimpleIdentifier labelNode = node.label;
1878 LabelElementImpl labelElement = lookupLabel(node, labelNode); 1878 LabelElementImpl labelElement = lookupLabel(node, labelNode);
1879 if (labelElement != null && labelElement.isOnSwitchMember()) { 1879 if (labelElement != null && labelElement.isOnSwitchMember) {
1880 _resolver.reportError(ResolverErrorCode.BREAK_LABEL_ON_SWITCH_MEMBER, labe lNode, []); 1880 _resolver.reportError(ResolverErrorCode.BREAK_LABEL_ON_SWITCH_MEMBER, labe lNode, []);
1881 } 1881 }
1882 return null; 1882 return null;
1883 } 1883 }
1884 Object visitClassDeclaration(ClassDeclaration node) { 1884 Object visitClassDeclaration(ClassDeclaration node) {
1885 setMetadata(node.element, node); 1885 setMetadata(node.element, node);
1886 return null; 1886 return null;
1887 } 1887 }
1888 Object visitClassTypeAlias(ClassTypeAlias node) { 1888 Object visitClassTypeAlias(ClassTypeAlias node) {
1889 setMetadata(node.element, node); 1889 setMetadata(node.element, node);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1982 } 1982 }
1983 setMetadata(constructorElement, node); 1983 setMetadata(constructorElement, node);
1984 } 1984 }
1985 return null; 1985 return null;
1986 } 1986 }
1987 Object visitConstructorFieldInitializer(ConstructorFieldInitializer node) { 1987 Object visitConstructorFieldInitializer(ConstructorFieldInitializer node) {
1988 SimpleIdentifier fieldName = node.fieldName; 1988 SimpleIdentifier fieldName = node.fieldName;
1989 ClassElement enclosingClass = _resolver.enclosingClass; 1989 ClassElement enclosingClass = _resolver.enclosingClass;
1990 FieldElement fieldElement = ((enclosingClass as ClassElementImpl)).getField( fieldName.name); 1990 FieldElement fieldElement = ((enclosingClass as ClassElementImpl)).getField( fieldName.name);
1991 recordResolution(fieldName, fieldElement); 1991 recordResolution(fieldName, fieldElement);
1992 if (fieldElement == null || fieldElement.isSynthetic()) { 1992 if (fieldElement == null || fieldElement.isSynthetic) {
1993 _resolver.reportError(CompileTimeErrorCode.INITIALIZER_FOR_NON_EXISTANT_FI ELD, node, [fieldName]); 1993 _resolver.reportError(CompileTimeErrorCode.INITIALIZER_FOR_NON_EXISTANT_FI ELD, node, [fieldName]);
1994 } else if (fieldElement.isStatic()) { 1994 } else if (fieldElement.isStatic) {
1995 _resolver.reportError(CompileTimeErrorCode.INITIALIZER_FOR_STATIC_FIELD, n ode, [fieldName]); 1995 _resolver.reportError(CompileTimeErrorCode.INITIALIZER_FOR_STATIC_FIELD, n ode, [fieldName]);
1996 } 1996 }
1997 return null; 1997 return null;
1998 } 1998 }
1999 Object visitConstructorName(ConstructorName node) { 1999 Object visitConstructorName(ConstructorName node) {
2000 Type2 type = node.type.type; 2000 Type2 type = node.type.type;
2001 if (type != null && type.isDynamic()) { 2001 if (type != null && type.isDynamic) {
2002 return null; 2002 return null;
2003 } else if (type is! InterfaceType) { 2003 } else if (type is! InterfaceType) {
2004 ASTNode parent = node.parent; 2004 ASTNode parent = node.parent;
2005 if (parent is InstanceCreationExpression) { 2005 if (parent is InstanceCreationExpression) {
2006 if (((parent as InstanceCreationExpression)).isConst()) { 2006 if (((parent as InstanceCreationExpression)).isConst) {
2007 } else { 2007 } else {
2008 } 2008 }
2009 } else { 2009 } else {
2010 } 2010 }
2011 return null; 2011 return null;
2012 } 2012 }
2013 ConstructorElement constructor; 2013 ConstructorElement constructor;
2014 SimpleIdentifier name = node.name; 2014 SimpleIdentifier name = node.name;
2015 InterfaceType interfaceType = type as InterfaceType; 2015 InterfaceType interfaceType = type as InterfaceType;
2016 LibraryElement definingLibrary = _resolver.definingLibrary; 2016 LibraryElement definingLibrary = _resolver.definingLibrary;
2017 if (name == null) { 2017 if (name == null) {
2018 constructor = interfaceType.lookUpConstructor(null, definingLibrary); 2018 constructor = interfaceType.lookUpConstructor(null, definingLibrary);
2019 } else { 2019 } else {
2020 constructor = interfaceType.lookUpConstructor(name.name, definingLibrary); 2020 constructor = interfaceType.lookUpConstructor(name.name, definingLibrary);
2021 name.staticElement = constructor; 2021 name.staticElement = constructor;
2022 name.element = constructor; 2022 name.element = constructor;
2023 } 2023 }
2024 node.staticElement = constructor; 2024 node.staticElement = constructor;
2025 node.element = constructor; 2025 node.element = constructor;
2026 return null; 2026 return null;
2027 } 2027 }
2028 Object visitContinueStatement(ContinueStatement node) { 2028 Object visitContinueStatement(ContinueStatement node) {
2029 SimpleIdentifier labelNode = node.label; 2029 SimpleIdentifier labelNode = node.label;
2030 LabelElementImpl labelElement = lookupLabel(node, labelNode); 2030 LabelElementImpl labelElement = lookupLabel(node, labelNode);
2031 if (labelElement != null && labelElement.isOnSwitchStatement()) { 2031 if (labelElement != null && labelElement.isOnSwitchStatement) {
2032 _resolver.reportError(ResolverErrorCode.CONTINUE_LABEL_ON_SWITCH, labelNod e, []); 2032 _resolver.reportError(ResolverErrorCode.CONTINUE_LABEL_ON_SWITCH, labelNod e, []);
2033 } 2033 }
2034 return null; 2034 return null;
2035 } 2035 }
2036 Object visitDeclaredIdentifier(DeclaredIdentifier node) { 2036 Object visitDeclaredIdentifier(DeclaredIdentifier node) {
2037 setMetadata(node.element, node); 2037 setMetadata(node.element, node);
2038 return null; 2038 return null;
2039 } 2039 }
2040 Object visitExportDirective(ExportDirective node) { 2040 Object visitExportDirective(ExportDirective node) {
2041 Element element = node.element; 2041 Element element = node.element;
(...skipping 13 matching lines...) Expand all
2055 } else { 2055 } else {
2056 ParameterElement parameterElement = node.element; 2056 ParameterElement parameterElement = node.element;
2057 if (parameterElement is FieldFormalParameterElementImpl) { 2057 if (parameterElement is FieldFormalParameterElementImpl) {
2058 FieldFormalParameterElementImpl fieldFormal = parameterElement as Fiel dFormalParameterElementImpl; 2058 FieldFormalParameterElementImpl fieldFormal = parameterElement as Fiel dFormalParameterElementImpl;
2059 fieldFormal.field = fieldElement; 2059 fieldFormal.field = fieldElement;
2060 Type2 declaredType = fieldFormal.type; 2060 Type2 declaredType = fieldFormal.type;
2061 Type2 fieldType = fieldElement.type; 2061 Type2 fieldType = fieldElement.type;
2062 if (node.type == null) { 2062 if (node.type == null) {
2063 fieldFormal.type = fieldType; 2063 fieldFormal.type = fieldType;
2064 } 2064 }
2065 if (fieldElement.isSynthetic()) { 2065 if (fieldElement.isSynthetic) {
2066 _resolver.reportError(CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_N ON_EXISTANT_FIELD, node, [fieldName]); 2066 _resolver.reportError(CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_N ON_EXISTANT_FIELD, node, [fieldName]);
2067 } else if (fieldElement.isStatic()) { 2067 } else if (fieldElement.isStatic) {
2068 _resolver.reportError(CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_S TATIC_FIELD, node, [fieldName]); 2068 _resolver.reportError(CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_S TATIC_FIELD, node, [fieldName]);
2069 } else if (declaredType != null && fieldType != null && !declaredType. isAssignableTo(fieldType)) { 2069 } else if (declaredType != null && fieldType != null && !declaredType. isAssignableTo(fieldType)) {
2070 _resolver.reportError(StaticWarningCode.FIELD_INITIALIZING_FORMAL_NO T_ASSIGNABLE, node, [declaredType.displayName, fieldType.displayName]); 2070 _resolver.reportError(StaticWarningCode.FIELD_INITIALIZING_FORMAL_NO T_ASSIGNABLE, node, [declaredType.displayName, fieldType.displayName]);
2071 } 2071 }
2072 } else { 2072 } else {
2073 if (fieldElement.isSynthetic()) { 2073 if (fieldElement.isSynthetic) {
2074 _resolver.reportError(CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_N ON_EXISTANT_FIELD, node, [fieldName]); 2074 _resolver.reportError(CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_N ON_EXISTANT_FIELD, node, [fieldName]);
2075 } else if (fieldElement.isStatic()) { 2075 } else if (fieldElement.isStatic) {
2076 _resolver.reportError(CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_S TATIC_FIELD, node, [fieldName]); 2076 _resolver.reportError(CompileTimeErrorCode.INITIALIZING_FORMAL_FOR_S TATIC_FIELD, node, [fieldName]);
2077 } 2077 }
2078 } 2078 }
2079 } 2079 }
2080 } 2080 }
2081 return super.visitFieldFormalParameter(node); 2081 return super.visitFieldFormalParameter(node);
2082 } 2082 }
2083 Object visitFunctionDeclaration(FunctionDeclaration node) { 2083 Object visitFunctionDeclaration(FunctionDeclaration node) {
2084 setMetadata(node.element, node); 2084 setMetadata(node.element, node);
2085 return null; 2085 return null;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2126 String methodName = sc.TokenType.INDEX_EQ.lexeme; 2126 String methodName = sc.TokenType.INDEX_EQ.lexeme;
2127 lookUpCheckIndexOperator(node, target, methodName, staticType, propagatedT ype); 2127 lookUpCheckIndexOperator(node, target, methodName, staticType, propagatedT ype);
2128 } 2128 }
2129 return null; 2129 return null;
2130 } 2130 }
2131 Object visitInstanceCreationExpression(InstanceCreationExpression node) { 2131 Object visitInstanceCreationExpression(InstanceCreationExpression node) {
2132 ConstructorElement invokedConstructor = node.constructorName.element; 2132 ConstructorElement invokedConstructor = node.constructorName.element;
2133 node.staticElement = invokedConstructor; 2133 node.staticElement = invokedConstructor;
2134 node.element = invokedConstructor; 2134 node.element = invokedConstructor;
2135 ArgumentList argumentList = node.argumentList; 2135 ArgumentList argumentList = node.argumentList;
2136 List<ParameterElement> parameters = resolveArgumentsToParameters(node.isCons t(), argumentList, invokedConstructor); 2136 List<ParameterElement> parameters = resolveArgumentsToParameters(node.isCons t, argumentList, invokedConstructor);
2137 if (parameters != null) { 2137 if (parameters != null) {
2138 argumentList.correspondingStaticParameters = parameters; 2138 argumentList.correspondingStaticParameters = parameters;
2139 } 2139 }
2140 return null; 2140 return null;
2141 } 2141 }
2142 Object visitLibraryDirective(LibraryDirective node) { 2142 Object visitLibraryDirective(LibraryDirective node) {
2143 setMetadata(node.element, node); 2143 setMetadata(node.element, node);
2144 return null; 2144 return null;
2145 } 2145 }
2146 Object visitMethodDeclaration(MethodDeclaration node) { 2146 Object visitMethodDeclaration(MethodDeclaration node) {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
2262 } 2262 }
2263 recordResolution(identifier, element); 2263 recordResolution(identifier, element);
2264 return null; 2264 return null;
2265 } 2265 }
2266 resolvePropertyAccess(prefix, identifier); 2266 resolvePropertyAccess(prefix, identifier);
2267 return null; 2267 return null;
2268 } 2268 }
2269 Object visitPrefixExpression(PrefixExpression node) { 2269 Object visitPrefixExpression(PrefixExpression node) {
2270 sc.Token operator = node.operator; 2270 sc.Token operator = node.operator;
2271 sc.TokenType operatorType = operator.type; 2271 sc.TokenType operatorType = operator.type;
2272 if (operatorType.isUserDefinableOperator() || identical(operatorType, sc.Tok enType.PLUS_PLUS) || identical(operatorType, sc.TokenType.MINUS_MINUS)) { 2272 if (operatorType.isUserDefinableOperator || identical(operatorType, sc.Token Type.PLUS_PLUS) || identical(operatorType, sc.TokenType.MINUS_MINUS)) {
2273 Expression operand = node.operand; 2273 Expression operand = node.operand;
2274 String methodName = getPrefixOperator(node); 2274 String methodName = getPrefixOperator(node);
2275 Type2 staticType = getStaticType(operand); 2275 Type2 staticType = getStaticType(operand);
2276 MethodElement staticMethod = lookUpMethod(operand, staticType, methodName) ; 2276 MethodElement staticMethod = lookUpMethod(operand, staticType, methodName) ;
2277 node.staticElement = staticMethod; 2277 node.staticElement = staticMethod;
2278 Type2 propagatedType = getPropagatedType(operand); 2278 Type2 propagatedType = getPropagatedType(operand);
2279 MethodElement propagatedMethod = lookUpMethod(operand, propagatedType, met hodName); 2279 MethodElement propagatedMethod = lookUpMethod(operand, propagatedType, met hodName);
2280 node.element = select3(staticMethod, propagatedMethod); 2280 node.element = select3(staticMethod, propagatedMethod);
2281 if (shouldReportMissingMember(staticType, staticMethod) && (_strictMode || propagatedType == null || shouldReportMissingMember(propagatedType, propagatedM ethod))) { 2281 if (shouldReportMissingMember(staticType, staticMethod) && (_strictMode || propagatedType == null || shouldReportMissingMember(propagatedType, propagatedM ethod))) {
2282 _resolver.reportError6(StaticTypeWarningCode.UNDEFINED_OPERATOR, operato r, [methodName, staticType.displayName]); 2282 _resolver.reportError6(StaticTypeWarningCode.UNDEFINED_OPERATOR, operato r, [methodName, staticType.displayName]);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
2354 element = superclass.getNamedConstructor(name.name); 2354 element = superclass.getNamedConstructor(name.name);
2355 } 2355 }
2356 if (element == null) { 2356 if (element == null) {
2357 if (name != null) { 2357 if (name != null) {
2358 _resolver.reportError(CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INIT IALIZER, node, [superclass.name, name]); 2358 _resolver.reportError(CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INIT IALIZER, node, [superclass.name, name]);
2359 } else { 2359 } else {
2360 _resolver.reportError(CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INIT IALIZER_DEFAULT, node, [superclass.name]); 2360 _resolver.reportError(CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INIT IALIZER_DEFAULT, node, [superclass.name]);
2361 } 2361 }
2362 return null; 2362 return null;
2363 } else { 2363 } else {
2364 if (element.isFactory()) { 2364 if (element.isFactory) {
2365 _resolver.reportError(CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR, n ode, [element]); 2365 _resolver.reportError(CompileTimeErrorCode.NON_GENERATIVE_CONSTRUCTOR, n ode, [element]);
2366 } 2366 }
2367 } 2367 }
2368 if (name != null) { 2368 if (name != null) {
2369 recordResolution(name, element); 2369 recordResolution(name, element);
2370 } 2370 }
2371 node.staticElement = element; 2371 node.staticElement = element;
2372 node.element = element; 2372 node.element = element;
2373 ArgumentList argumentList = node.argumentList; 2373 ArgumentList argumentList = node.argumentList;
2374 List<ParameterElement> parameters = resolveArgumentsToParameters(false, argu mentList, element); 2374 List<ParameterElement> parameters = resolveArgumentsToParameters(false, argu mentList, element);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
2461 if (!classDeclaresNoSuchMethod(enclosingClass)) { 2461 if (!classDeclaresNoSuchMethod(enclosingClass)) {
2462 return StaticTypeWarningCode.UNDEFINED_METHOD; 2462 return StaticTypeWarningCode.UNDEFINED_METHOD;
2463 } 2463 }
2464 } else { 2464 } else {
2465 return StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION; 2465 return StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION;
2466 } 2466 }
2467 } else { 2467 } else {
2468 Type2 targetType = getStaticType(target); 2468 Type2 targetType = getStaticType(target);
2469 if (targetType == null) { 2469 if (targetType == null) {
2470 return StaticTypeWarningCode.UNDEFINED_FUNCTION; 2470 return StaticTypeWarningCode.UNDEFINED_FUNCTION;
2471 } else if (!targetType.isDynamic() && !classDeclaresNoSuchMethod2(targ etType.element)) { 2471 } else if (!targetType.isDynamic && !classDeclaresNoSuchMethod2(target Type.element)) {
2472 return StaticTypeWarningCode.UNDEFINED_METHOD; 2472 return StaticTypeWarningCode.UNDEFINED_METHOD;
2473 } 2473 }
2474 } 2474 }
2475 } 2475 }
2476 } 2476 }
2477 return null; 2477 return null;
2478 } 2478 }
2479 2479
2480 /** 2480 /**
2481 * Return `true` if the given class declares a method named "noSuchMethod" and is not the 2481 * Return `true` if the given class declares a method named "noSuchMethod" and is not the
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
2658 return superType.element; 2658 return superType.element;
2659 } 2659 }
2660 2660
2661 /** 2661 /**
2662 * Return `true` if the given type represents an object that could be invoked using the call 2662 * Return `true` if the given type represents an object that could be invoked using the call
2663 * operator '()'. 2663 * operator '()'.
2664 * @param type the type being tested 2664 * @param type the type being tested
2665 * @return `true` if the given type represents an object that could be invoked 2665 * @return `true` if the given type represents an object that could be invoked
2666 */ 2666 */
2667 bool isExecutableType(Type2 type) { 2667 bool isExecutableType(Type2 type) {
2668 if (type.isDynamic() || (type is FunctionType) || type.isDartCoreFunction()) { 2668 if (type.isDynamic || (type is FunctionType) || type.isDartCoreFunction) {
2669 return true; 2669 return true;
2670 } else if (type is InterfaceType) { 2670 } else if (type is InterfaceType) {
2671 ClassElement classElement = ((type as InterfaceType)).element; 2671 ClassElement classElement = ((type as InterfaceType)).element;
2672 MethodElement methodElement = classElement.lookUpMethod(CALL_METHOD_NAME, _resolver.definingLibrary); 2672 MethodElement methodElement = classElement.lookUpMethod(CALL_METHOD_NAME, _resolver.definingLibrary);
2673 return methodElement != null; 2673 return methodElement != null;
2674 } 2674 }
2675 return false; 2675 return false;
2676 } 2676 }
2677 2677
2678 /** 2678 /**
2679 * Return `true` if the given element is a static element. 2679 * Return `true` if the given element is a static element.
2680 * @param element the element being tested 2680 * @param element the element being tested
2681 * @return `true` if the given element is a static element 2681 * @return `true` if the given element is a static element
2682 */ 2682 */
2683 bool isStatic(Element element) { 2683 bool isStatic(Element element) {
2684 if (element is ExecutableElement) { 2684 if (element is ExecutableElement) {
2685 return ((element as ExecutableElement)).isStatic(); 2685 return ((element as ExecutableElement)).isStatic;
2686 } else if (element is PropertyInducingElement) { 2686 } else if (element is PropertyInducingElement) {
2687 return ((element as PropertyInducingElement)).isStatic(); 2687 return ((element as PropertyInducingElement)).isStatic;
2688 } 2688 }
2689 return false; 2689 return false;
2690 } 2690 }
2691 2691
2692 /** 2692 /**
2693 * Looks up the method element with the given name for index expression, repor ts[StaticWarningCode#UNDEFINED_OPERATOR] if not found. 2693 * Looks up the method element with the given name for index expression, repor ts[StaticWarningCode#UNDEFINED_OPERATOR] if not found.
2694 * @param node the index expression to resolve 2694 * @param node the index expression to resolve
2695 * @param target the target of the expression 2695 * @param target the target of the expression
2696 * @param methodName the name of the operator associated with the context of u sing of the given 2696 * @param methodName the name of the operator associated with the context of u sing of the given
2697 * index expression 2697 * index expression
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
3426 } 3426 }
3427 3427
3428 /** 3428 /**
3429 * Return `true` if we should report an error as a result of looking up a memb er in the 3429 * Return `true` if we should report an error as a result of looking up a memb er in the
3430 * given type and not finding any member. 3430 * given type and not finding any member.
3431 * @param type the type in which we attempted to perform the look-up 3431 * @param type the type in which we attempted to perform the look-up
3432 * @param member the result of the look-up 3432 * @param member the result of the look-up
3433 * @return `true` if we should report an error 3433 * @return `true` if we should report an error
3434 */ 3434 */
3435 bool shouldReportMissingMember(Type2 type, ExecutableElement member) { 3435 bool shouldReportMissingMember(Type2 type, ExecutableElement member) {
3436 if (member != null || type == null || type.isDynamic()) { 3436 if (member != null || type == null || type.isDynamic) {
3437 return false; 3437 return false;
3438 } 3438 }
3439 if (type is InterfaceType) { 3439 if (type is InterfaceType) {
3440 return !classDeclaresNoSuchMethod(((type as InterfaceType)).element); 3440 return !classDeclaresNoSuchMethod(((type as InterfaceType)).element);
3441 } 3441 }
3442 return true; 3442 return true;
3443 } 3443 }
3444 } 3444 }
3445 /** 3445 /**
3446 * Instances of the class `SyntheticIdentifier` implement an identifier that can be used to 3446 * Instances of the class `SyntheticIdentifier` implement an identifier that can be used to
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
3708 Map<String, ExecutableElement> computeInterfaceLookupMap(ClassElement classElt , Set<ClassElement> visitedInterfaces) { 3708 Map<String, ExecutableElement> computeInterfaceLookupMap(ClassElement classElt , Set<ClassElement> visitedInterfaces) {
3709 Map<String, ExecutableElement> resultMap = _interfaceLookup[classElt]; 3709 Map<String, ExecutableElement> resultMap = _interfaceLookup[classElt];
3710 if (resultMap != null) { 3710 if (resultMap != null) {
3711 return resultMap; 3711 return resultMap;
3712 } else { 3712 } else {
3713 resultMap = new Map<String, ExecutableElement>(); 3713 resultMap = new Map<String, ExecutableElement>();
3714 } 3714 }
3715 InterfaceType supertype = classElt.supertype; 3715 InterfaceType supertype = classElt.supertype;
3716 ClassElement superclassElement = supertype != null ? supertype.element : nul l; 3716 ClassElement superclassElement = supertype != null ? supertype.element : nul l;
3717 List<InterfaceType> interfaces = classElt.interfaces; 3717 List<InterfaceType> interfaces = classElt.interfaces;
3718 if ((superclassElement == null || supertype.isObject()) && interfaces.length == 0) { 3718 if ((superclassElement == null || supertype.isObject) && interfaces.length = = 0) {
3719 _interfaceLookup[classElt] = resultMap; 3719 _interfaceLookup[classElt] = resultMap;
3720 return resultMap; 3720 return resultMap;
3721 } 3721 }
3722 List<Map<String, ExecutableElement>> lookupMaps = new List<Map<String, Execu tableElement>>(); 3722 List<Map<String, ExecutableElement>> lookupMaps = new List<Map<String, Execu tableElement>>();
3723 if (superclassElement != null) { 3723 if (superclassElement != null) {
3724 if (!visitedInterfaces.contains(superclassElement)) { 3724 if (!visitedInterfaces.contains(superclassElement)) {
3725 try { 3725 try {
3726 javaSetAdd(visitedInterfaces, superclassElement); 3726 javaSetAdd(visitedInterfaces, superclassElement);
3727 lookupMaps.add(computeInterfaceLookupMap(superclassElement, visitedInt erfaces)); 3727 lookupMaps.add(computeInterfaceLookupMap(superclassElement, visitedInt erfaces));
3728 } finally { 3728 } finally {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
3772 javaSetAdd(set, entry.getValue()); 3772 javaSetAdd(set, entry.getValue());
3773 unionMap[key] = set; 3773 unionMap[key] = set;
3774 } else { 3774 } else {
3775 javaSetAdd(unionMap[key], entry.getValue()); 3775 javaSetAdd(unionMap[key], entry.getValue());
3776 } 3776 }
3777 } 3777 }
3778 } 3778 }
3779 if (superclassElement != null) { 3779 if (superclassElement != null) {
3780 List<MethodElement> methods = superclassElement.methods; 3780 List<MethodElement> methods = superclassElement.methods;
3781 for (MethodElement method in methods) { 3781 for (MethodElement method in methods) {
3782 if (method.isAccessibleIn(_library) && !method.isStatic()) { 3782 if (method.isAccessibleIn(_library) && !method.isStatic) {
3783 String key = method.name; 3783 String key = method.name;
3784 if (!unionMap.containsKey(key)) { 3784 if (!unionMap.containsKey(key)) {
3785 Set<ExecutableElement> set = new Set<ExecutableElement>(); 3785 Set<ExecutableElement> set = new Set<ExecutableElement>();
3786 javaSetAdd(set, method); 3786 javaSetAdd(set, method);
3787 unionMap[key] = set; 3787 unionMap[key] = set;
3788 } else { 3788 } else {
3789 javaSetAdd(unionMap[key], method); 3789 javaSetAdd(unionMap[key], method);
3790 } 3790 }
3791 } 3791 }
3792 } 3792 }
3793 List<PropertyAccessorElement> accessors = superclassElement.accessors; 3793 List<PropertyAccessorElement> accessors = superclassElement.accessors;
3794 for (PropertyAccessorElement accessor in accessors) { 3794 for (PropertyAccessorElement accessor in accessors) {
3795 if (accessor.isAccessibleIn(_library) && !accessor.isStatic()) { 3795 if (accessor.isAccessibleIn(_library) && !accessor.isStatic) {
3796 String key = accessor.name; 3796 String key = accessor.name;
3797 if (!unionMap.containsKey(key)) { 3797 if (!unionMap.containsKey(key)) {
3798 Set<ExecutableElement> set = new Set<ExecutableElement>(); 3798 Set<ExecutableElement> set = new Set<ExecutableElement>();
3799 javaSetAdd(set, accessor); 3799 javaSetAdd(set, accessor);
3800 unionMap[key] = set; 3800 unionMap[key] = set;
3801 } else { 3801 } else {
3802 javaSetAdd(unionMap[key], accessor); 3802 javaSetAdd(unionMap[key], accessor);
3803 } 3803 }
3804 } 3804 }
3805 } 3805 }
3806 } 3806 }
3807 for (InterfaceType interfaceType in interfaces) { 3807 for (InterfaceType interfaceType in interfaces) {
3808 ClassElement interfaceElement = interfaceType.element; 3808 ClassElement interfaceElement = interfaceType.element;
3809 if (interfaceElement != null) { 3809 if (interfaceElement != null) {
3810 List<MethodElement> methods = interfaceElement.methods; 3810 List<MethodElement> methods = interfaceElement.methods;
3811 for (MethodElement method in methods) { 3811 for (MethodElement method in methods) {
3812 if (method.isAccessibleIn(_library) && !method.isStatic()) { 3812 if (method.isAccessibleIn(_library) && !method.isStatic) {
3813 String key = method.name; 3813 String key = method.name;
3814 if (!unionMap.containsKey(key)) { 3814 if (!unionMap.containsKey(key)) {
3815 Set<ExecutableElement> set = new Set<ExecutableElement>(); 3815 Set<ExecutableElement> set = new Set<ExecutableElement>();
3816 javaSetAdd(set, method); 3816 javaSetAdd(set, method);
3817 unionMap[key] = set; 3817 unionMap[key] = set;
3818 } else { 3818 } else {
3819 javaSetAdd(unionMap[key], method); 3819 javaSetAdd(unionMap[key], method);
3820 } 3820 }
3821 } 3821 }
3822 } 3822 }
3823 List<PropertyAccessorElement> accessors = interfaceElement.accessors; 3823 List<PropertyAccessorElement> accessors = interfaceElement.accessors;
3824 for (PropertyAccessorElement accessor in accessors) { 3824 for (PropertyAccessorElement accessor in accessors) {
3825 if (accessor.isAccessibleIn(_library) && !accessor.isStatic()) { 3825 if (accessor.isAccessibleIn(_library) && !accessor.isStatic) {
3826 String key = accessor.name; 3826 String key = accessor.name;
3827 if (!unionMap.containsKey(key)) { 3827 if (!unionMap.containsKey(key)) {
3828 Set<ExecutableElement> set = new Set<ExecutableElement>(); 3828 Set<ExecutableElement> set = new Set<ExecutableElement>();
3829 javaSetAdd(set, accessor); 3829 javaSetAdd(set, accessor);
3830 unionMap[key] = set; 3830 unionMap[key] = set;
3831 } else { 3831 } else {
3832 javaSetAdd(unionMap[key], accessor); 3832 javaSetAdd(unionMap[key], accessor);
3833 } 3833 }
3834 } 3834 }
3835 } 3835 }
3836 } 3836 }
3837 } 3837 }
3838 for (MapEntry<String, Set<ExecutableElement>> entry in getMapEntrySet(unionM ap)) { 3838 for (MapEntry<String, Set<ExecutableElement>> entry in getMapEntrySet(unionM ap)) {
3839 String key = entry.getKey(); 3839 String key = entry.getKey();
3840 Set<ExecutableElement> set = entry.getValue(); 3840 Set<ExecutableElement> set = entry.getValue();
3841 int numOfEltsWithMatchingNames = set.length; 3841 int numOfEltsWithMatchingNames = set.length;
3842 if (numOfEltsWithMatchingNames == 1) { 3842 if (numOfEltsWithMatchingNames == 1) {
3843 resultMap[key] = new JavaIterator(set).next(); 3843 resultMap[key] = new JavaIterator(set).next();
3844 } else { 3844 } else {
3845 bool allMethods = true; 3845 bool allMethods = true;
3846 bool allSetters = true; 3846 bool allSetters = true;
3847 bool allGetters = true; 3847 bool allGetters = true;
3848 for (ExecutableElement executableElement in set) { 3848 for (ExecutableElement executableElement in set) {
3849 if (executableElement is PropertyAccessorElement) { 3849 if (executableElement is PropertyAccessorElement) {
3850 allMethods = false; 3850 allMethods = false;
3851 if (((executableElement as PropertyAccessorElement)).isSetter()) { 3851 if (((executableElement as PropertyAccessorElement)).isSetter) {
3852 allGetters = false; 3852 allGetters = false;
3853 } else { 3853 } else {
3854 allSetters = false; 3854 allSetters = false;
3855 } 3855 }
3856 } else { 3856 } else {
3857 allGetters = false; 3857 allGetters = false;
3858 allSetters = false; 3858 allSetters = false;
3859 } 3859 }
3860 } 3860 }
3861 if (allMethods || allGetters || allSetters) { 3861 if (allMethods || allGetters || allSetters) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
3904 * Given some [ClassElement], this method finds and returns the [ExecutableEle ment] of 3904 * Given some [ClassElement], this method finds and returns the [ExecutableEle ment] of
3905 * the passed name in the class element. Static members, members in super type s and members not 3905 * the passed name in the class element. Static members, members in super type s and members not
3906 * accessible from the current library are not considered. 3906 * accessible from the current library are not considered.
3907 * @param classElt the class element to query 3907 * @param classElt the class element to query
3908 * @param memberName the name of the member to lookup in the class 3908 * @param memberName the name of the member to lookup in the class
3909 * @return the found [ExecutableElement], or `null` if no such member was foun d 3909 * @return the found [ExecutableElement], or `null` if no such member was foun d
3910 */ 3910 */
3911 ExecutableElement lookupMemberInClass(ClassElement classElt, String memberName ) { 3911 ExecutableElement lookupMemberInClass(ClassElement classElt, String memberName ) {
3912 List<MethodElement> methods = classElt.methods; 3912 List<MethodElement> methods = classElt.methods;
3913 for (MethodElement method in methods) { 3913 for (MethodElement method in methods) {
3914 if (memberName == method.name && method.isAccessibleIn(_library) && !metho d.isStatic()) { 3914 if (memberName == method.name && method.isAccessibleIn(_library) && !metho d.isStatic) {
3915 return method; 3915 return method;
3916 } 3916 }
3917 } 3917 }
3918 List<PropertyAccessorElement> accessors = classElt.accessors; 3918 List<PropertyAccessorElement> accessors = classElt.accessors;
3919 for (PropertyAccessorElement accessor in accessors) { 3919 for (PropertyAccessorElement accessor in accessors) {
3920 if (memberName == accessor.name && accessor.isAccessibleIn(_library) && !a ccessor.isStatic()) { 3920 if (memberName == accessor.name && accessor.isAccessibleIn(_library) && !a ccessor.isStatic) {
3921 return accessor; 3921 return accessor;
3922 } 3922 }
3923 } 3923 }
3924 return null; 3924 return null;
3925 } 3925 }
3926 3926
3927 /** 3927 /**
3928 * Record the passed map with the set of all members (methods, getters and set ters) in the class 3928 * Record the passed map with the set of all members (methods, getters and set ters) in the class
3929 * into the passed map. 3929 * into the passed map.
3930 * @param map some non-`null` 3930 * @param map some non-`null`
3931 * @param classElt the class element that will be recorded into the passed map 3931 * @param classElt the class element that will be recorded into the passed map
3932 */ 3932 */
3933 void recordMapWithClassMembers(Map<String, ExecutableElement> map, ClassElemen t classElt) { 3933 void recordMapWithClassMembers(Map<String, ExecutableElement> map, ClassElemen t classElt) {
3934 List<MethodElement> methods = classElt.methods; 3934 List<MethodElement> methods = classElt.methods;
3935 for (MethodElement method in methods) { 3935 for (MethodElement method in methods) {
3936 if (method.isAccessibleIn(_library) && !method.isStatic()) { 3936 if (method.isAccessibleIn(_library) && !method.isStatic) {
3937 map[method.name] = method; 3937 map[method.name] = method;
3938 } 3938 }
3939 } 3939 }
3940 List<PropertyAccessorElement> accessors = classElt.accessors; 3940 List<PropertyAccessorElement> accessors = classElt.accessors;
3941 for (PropertyAccessorElement accessor in accessors) { 3941 for (PropertyAccessorElement accessor in accessors) {
3942 if (accessor.isAccessibleIn(_library) && !accessor.isStatic()) { 3942 if (accessor.isAccessibleIn(_library) && !accessor.isStatic) {
3943 map[accessor.name] = accessor; 3943 map[accessor.name] = accessor;
3944 } 3944 }
3945 } 3945 }
3946 } 3946 }
3947 3947
3948 /** 3948 /**
3949 * This method is used to report errors on when they are found computing inher itance information. 3949 * This method is used to report errors on when they are found computing inher itance information.
3950 * See [ErrorVerifier#checkForInconsistentMethodInheritance] to see where thes e generated 3950 * See [ErrorVerifier#checkForInconsistentMethodInheritance] to see where thes e generated
3951 * error codes are reported back into the analysis engine. 3951 * error codes are reported back into the analysis engine.
3952 * @param classElt the location of the source for which the exception occurred 3952 * @param classElt the location of the source for which the exception occurred
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
4354 4354
4355 /** 4355 /**
4356 * Add all of the non-synthetic getters and setters defined in the given compi lation unit that 4356 * Add all of the non-synthetic getters and setters defined in the given compi lation unit that
4357 * have no corresponding accessor to one of the given collections. 4357 * have no corresponding accessor to one of the given collections.
4358 * @param getters the map to which getters are to be added 4358 * @param getters the map to which getters are to be added
4359 * @param setters the list to which setters are to be added 4359 * @param setters the list to which setters are to be added
4360 * @param unit the compilation unit defining the accessors that are potentiall y being added 4360 * @param unit the compilation unit defining the accessors that are potentiall y being added
4361 */ 4361 */
4362 void collectAccessors(Map<String, PropertyAccessorElement> getters, List<Prope rtyAccessorElement> setters, CompilationUnitElement unit) { 4362 void collectAccessors(Map<String, PropertyAccessorElement> getters, List<Prope rtyAccessorElement> setters, CompilationUnitElement unit) {
4363 for (PropertyAccessorElement accessor in unit.accessors) { 4363 for (PropertyAccessorElement accessor in unit.accessors) {
4364 if (accessor.isGetter()) { 4364 if (accessor.isGetter) {
4365 if (!accessor.isSynthetic() && accessor.correspondingSetter == null) { 4365 if (!accessor.isSynthetic && accessor.correspondingSetter == null) {
4366 getters[accessor.displayName] = accessor; 4366 getters[accessor.displayName] = accessor;
4367 } 4367 }
4368 } else { 4368 } else {
4369 if (!accessor.isSynthetic() && accessor.correspondingGetter == null) { 4369 if (!accessor.isSynthetic && accessor.correspondingGetter == null) {
4370 setters.add(accessor); 4370 setters.add(accessor);
4371 } 4371 }
4372 } 4372 }
4373 } 4373 }
4374 } 4374 }
4375 4375
4376 /** 4376 /**
4377 * Search the top-level functions defined in the given compilation unit for th e entry point. 4377 * Search the top-level functions defined in the given compilation unit for th e entry point.
4378 * @param element the compilation unit to be searched 4378 * @param element the compilation unit to be searched
4379 * @return the entry point that was found, or `null` if the compilation unit d oes not define 4379 * @return the entry point that was found, or `null` if the compilation unit d oes not define
(...skipping 1119 matching lines...) Expand 10 before | Expand all | Expand 10 after
5499 * type. 5499 * type.
5500 * @param element the element whose type might be overridden 5500 * @param element the element whose type might be overridden
5501 * @param potentialType the potential type of the element 5501 * @param potentialType the potential type of the element
5502 */ 5502 */
5503 void override(VariableElement element, Type2 potentialType) { 5503 void override(VariableElement element, Type2 potentialType) {
5504 if (potentialType == null || identical(potentialType, BottomTypeImpl.instanc e)) { 5504 if (potentialType == null || identical(potentialType, BottomTypeImpl.instanc e)) {
5505 return; 5505 return;
5506 } 5506 }
5507 if (element is PropertyInducingElement) { 5507 if (element is PropertyInducingElement) {
5508 PropertyInducingElement variable = element as PropertyInducingElement; 5508 PropertyInducingElement variable = element as PropertyInducingElement;
5509 if (!variable.isConst() && !variable.isFinal()) { 5509 if (!variable.isConst && !variable.isFinal) {
5510 return; 5510 return;
5511 } 5511 }
5512 } 5512 }
5513 Type2 currentType = getBestType(element); 5513 Type2 currentType = getBestType(element);
5514 if (currentType == null || !currentType.isMoreSpecificThan(potentialType)) { 5514 if (currentType == null || !currentType.isMoreSpecificThan(potentialType)) {
5515 _overrideManager.setType(element, potentialType); 5515 _overrideManager.setType(element, potentialType);
5516 } 5516 }
5517 } 5517 }
5518 void visitForEachStatementInScope(ForEachStatement node) { 5518 void visitForEachStatementInScope(ForEachStatement node) {
5519 Expression iterator = node.iterator; 5519 Expression iterator = node.iterator;
(...skipping 1687 matching lines...) Expand 10 before | Expand all | Expand 10 after
7207 } 7207 }
7208 MethodElement callMethod = ((returnType as InterfaceType)).lookUpMetho d(ElementResolver.CALL_METHOD_NAME, _resolver.definingLibrary); 7208 MethodElement callMethod = ((returnType as InterfaceType)).lookUpMetho d(ElementResolver.CALL_METHOD_NAME, _resolver.definingLibrary);
7209 if (callMethod != null) { 7209 if (callMethod != null) {
7210 return callMethod.type.returnType; 7210 return callMethod.type.returnType;
7211 } 7211 }
7212 } else if (returnType is FunctionType) { 7212 } else if (returnType is FunctionType) {
7213 Type2 innerReturnType = ((returnType as FunctionType)).returnType; 7213 Type2 innerReturnType = ((returnType as FunctionType)).returnType;
7214 if (innerReturnType != null) { 7214 if (innerReturnType != null) {
7215 return innerReturnType; 7215 return innerReturnType;
7216 } 7216 }
7217 } else if (returnType.isDartCoreFunction()) { 7217 } else if (returnType.isDartCoreFunction) {
7218 return _dynamicType; 7218 return _dynamicType;
7219 } 7219 }
7220 if (returnType != null) { 7220 if (returnType != null) {
7221 return returnType; 7221 return returnType;
7222 } 7222 }
7223 } 7223 }
7224 } else if (element is ExecutableElement) { 7224 } else if (element is ExecutableElement) {
7225 FunctionType type = ((element as ExecutableElement)).type; 7225 FunctionType type = ((element as ExecutableElement)).type;
7226 if (type != null) { 7226 if (type != null) {
7227 return type.returnType; 7227 return type.returnType;
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
7388 * @param context if the accessor element has context \[by being the RHS of a[ PrefixedIdentifier] or [PropertyAccess]\], and the return type of the 7388 * @param context if the accessor element has context \[by being the RHS of a[ PrefixedIdentifier] or [PropertyAccess]\], and the return type of the
7389 * accessor is a parameter type, then the type of the LHS can be used to get m ore 7389 * accessor is a parameter type, then the type of the LHS can be used to get m ore
7390 * specific type information 7390 * specific type information
7391 * @return the type that should be recorded for a node that resolved to the gi ven accessor 7391 * @return the type that should be recorded for a node that resolved to the gi ven accessor
7392 */ 7392 */
7393 Type2 getType(PropertyAccessorElement accessor, Type2 context) { 7393 Type2 getType(PropertyAccessorElement accessor, Type2 context) {
7394 FunctionType functionType = accessor.type; 7394 FunctionType functionType = accessor.type;
7395 if (functionType == null) { 7395 if (functionType == null) {
7396 return _dynamicType; 7396 return _dynamicType;
7397 } 7397 }
7398 if (accessor.isSetter()) { 7398 if (accessor.isSetter) {
7399 List<Type2> parameterTypes = functionType.normalParameterTypes; 7399 List<Type2> parameterTypes = functionType.normalParameterTypes;
7400 if (parameterTypes != null && parameterTypes.length > 0) { 7400 if (parameterTypes != null && parameterTypes.length > 0) {
7401 return parameterTypes[0]; 7401 return parameterTypes[0];
7402 } 7402 }
7403 PropertyAccessorElement getter = accessor.variable.getter; 7403 PropertyAccessorElement getter = accessor.variable.getter;
7404 if (getter != null) { 7404 if (getter != null) {
7405 functionType = getter.type; 7405 functionType = getter.type;
7406 if (functionType != null) { 7406 if (functionType != null) {
7407 return functionType.returnType; 7407 return functionType.returnType;
7408 } 7408 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
7454 ASTNode parent = node.parent; 7454 ASTNode parent = node.parent;
7455 return parent is TypeName || (parent is PrefixedIdentifier && (parent.parent is TypeName || identical(((parent as PrefixedIdentifier)).prefix, node))) || (p arent is PropertyAccess && identical(((parent as PropertyAccess)).target, node)) || (parent is MethodInvocation && identical(node, ((parent as MethodInvocation) ).target)); 7455 return parent is TypeName || (parent is PrefixedIdentifier && (parent.parent is TypeName || identical(((parent as PrefixedIdentifier)).prefix, node))) || (p arent is PropertyAccess && identical(((parent as PropertyAccess)).target, node)) || (parent is MethodInvocation && identical(node, ((parent as MethodInvocation) ).target));
7456 } 7456 }
7457 7457
7458 /** 7458 /**
7459 * Record that the propagated type of the given node is the given type. 7459 * Record that the propagated type of the given node is the given type.
7460 * @param expression the node whose type is to be recorded 7460 * @param expression the node whose type is to be recorded
7461 * @param type the propagated type of the node 7461 * @param type the propagated type of the node
7462 */ 7462 */
7463 void recordPropagatedType(Expression expression, Type2 type) { 7463 void recordPropagatedType(Expression expression, Type2 type) {
7464 if (type != null && !type.isDynamic()) { 7464 if (type != null && !type.isDynamic) {
7465 expression.propagatedType = type; 7465 expression.propagatedType = type;
7466 } 7466 }
7467 } 7467 }
7468 7468
7469 /** 7469 /**
7470 * Record that the static type of the given node is the given type. 7470 * Record that the static type of the given node is the given type.
7471 * @param expression the node whose type is to be recorded 7471 * @param expression the node whose type is to be recorded
7472 * @param type the static type of the node 7472 * @param type the static type of the node
7473 */ 7473 */
7474 void recordStaticType(Expression expression, Type2 type) { 7474 void recordStaticType(Expression expression, Type2 type) {
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
7667 Map<Element, Type2> captureLocalOverrides() => _overridenTypes; 7667 Map<Element, Type2> captureLocalOverrides() => _overridenTypes;
7668 7668
7669 /** 7669 /**
7670 * Return a map from the elements for the variables in the given list that hav e their types 7670 * Return a map from the elements for the variables in the given list that hav e their types
7671 * overridden to the overriding type. 7671 * overridden to the overriding type.
7672 * @param variableList the list of variables whose overriding types are to be captured 7672 * @param variableList the list of variables whose overriding types are to be captured
7673 * @return a table mapping elements to their overriding types 7673 * @return a table mapping elements to their overriding types
7674 */ 7674 */
7675 Map<Element, Type2> captureOverrides(VariableDeclarationList variableList) { 7675 Map<Element, Type2> captureOverrides(VariableDeclarationList variableList) {
7676 Map<Element, Type2> overrides = new Map<Element, Type2>(); 7676 Map<Element, Type2> overrides = new Map<Element, Type2>();
7677 if (variableList.isConst() || variableList.isFinal()) { 7677 if (variableList.isConst || variableList.isFinal) {
7678 for (VariableDeclaration variable in variableList.variables) { 7678 for (VariableDeclaration variable in variableList.variables) {
7679 Element element = variable.element; 7679 Element element = variable.element;
7680 if (element != null) { 7680 if (element != null) {
7681 Type2 type = _overridenTypes[element]; 7681 Type2 type = _overridenTypes[element];
7682 if (type != null) { 7682 if (type != null) {
7683 overrides[element] = type; 7683 overrides[element] = type;
7684 } 7684 }
7685 } 7685 }
7686 } 7686 }
7687 } 7687 }
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
8140 FunctionTypeImpl type = new FunctionTypeImpl.con1(element); 8140 FunctionTypeImpl type = new FunctionTypeImpl.con1(element);
8141 ClassElement definingClass = element.getAncestor(ClassElement); 8141 ClassElement definingClass = element.getAncestor(ClassElement);
8142 if (definingClass != null) { 8142 if (definingClass != null) {
8143 type.typeArguments = definingClass.type.typeArguments; 8143 type.typeArguments = definingClass.type.typeArguments;
8144 } 8144 }
8145 setTypeInformation(type, element.parameters); 8145 setTypeInformation(type, element.parameters);
8146 element.type = type; 8146 element.type = type;
8147 if (element is PropertyAccessorElement) { 8147 if (element is PropertyAccessorElement) {
8148 PropertyAccessorElement accessor = element as PropertyAccessorElement; 8148 PropertyAccessorElement accessor = element as PropertyAccessorElement;
8149 PropertyInducingElementImpl variable = accessor.variable as PropertyInduci ngElementImpl; 8149 PropertyInducingElementImpl variable = accessor.variable as PropertyInduci ngElementImpl;
8150 if (accessor.isGetter()) { 8150 if (accessor.isGetter) {
8151 variable.type = type.returnType; 8151 variable.type = type.returnType;
8152 } else if (variable.type == null) { 8152 } else if (variable.type == null) {
8153 List<Type2> parameterTypes = type.normalParameterTypes; 8153 List<Type2> parameterTypes = type.normalParameterTypes;
8154 if (parameterTypes != null && parameterTypes.length > 0) { 8154 if (parameterTypes != null && parameterTypes.length > 0) {
8155 variable.type = parameterTypes[0]; 8155 variable.type = parameterTypes[0];
8156 } 8156 }
8157 } 8157 }
8158 } 8158 }
8159 return null; 8159 return null;
8160 } 8160 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
8214 node.name = prefix; 8214 node.name = prefix;
8215 typeName = prefix; 8215 typeName = prefix;
8216 } 8216 }
8217 } 8217 }
8218 } 8218 }
8219 } 8219 }
8220 bool elementValid = element is! MultiplyDefinedElement; 8220 bool elementValid = element is! MultiplyDefinedElement;
8221 if (elementValid && element is! ClassElement && isTypeNameInInstanceCreation Expression(node)) { 8221 if (elementValid && element is! ClassElement && isTypeNameInInstanceCreation Expression(node)) {
8222 SimpleIdentifier typeNameSimple = getTypeSimpleIdentifier(typeName); 8222 SimpleIdentifier typeNameSimple = getTypeSimpleIdentifier(typeName);
8223 InstanceCreationExpression creation = node.parent.parent as InstanceCreati onExpression; 8223 InstanceCreationExpression creation = node.parent.parent as InstanceCreati onExpression;
8224 if (creation.isConst()) { 8224 if (creation.isConst) {
8225 if (element == null) { 8225 if (element == null) {
8226 reportError(CompileTimeErrorCode.UNDEFINED_CLASS, typeNameSimple, [typ eName]); 8226 reportError(CompileTimeErrorCode.UNDEFINED_CLASS, typeNameSimple, [typ eName]);
8227 } else { 8227 } else {
8228 reportError(CompileTimeErrorCode.CONST_WITH_NON_TYPE, typeNameSimple, [typeName]); 8228 reportError(CompileTimeErrorCode.CONST_WITH_NON_TYPE, typeNameSimple, [typeName]);
8229 } 8229 }
8230 elementValid = false; 8230 elementValid = false;
8231 } else { 8231 } else {
8232 if (element != null) { 8232 if (element != null) {
8233 reportError(StaticWarningCode.NEW_WITH_NON_TYPE, typeNameSimple, [type Name]); 8233 reportError(StaticWarningCode.NEW_WITH_NON_TYPE, typeNameSimple, [type Name]);
8234 elementValid = false; 8234 elementValid = false;
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
8435 * error. 8435 * error.
8436 * @param node the type name with the wrong number of type arguments 8436 * @param node the type name with the wrong number of type arguments
8437 * @return the error code that should be used to report that the wrong number of type arguments 8437 * @return the error code that should be used to report that the wrong number of type arguments
8438 * were provided 8438 * were provided
8439 */ 8439 */
8440 ErrorCode getInvalidTypeParametersErrorCode(TypeName node) { 8440 ErrorCode getInvalidTypeParametersErrorCode(TypeName node) {
8441 ASTNode parent = node.parent; 8441 ASTNode parent = node.parent;
8442 if (parent is ConstructorName) { 8442 if (parent is ConstructorName) {
8443 parent = parent.parent; 8443 parent = parent.parent;
8444 if (parent is InstanceCreationExpression) { 8444 if (parent is InstanceCreationExpression) {
8445 if (((parent as InstanceCreationExpression)).isConst()) { 8445 if (((parent as InstanceCreationExpression)).isConst) {
8446 return CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETERS; 8446 return CompileTimeErrorCode.CONST_WITH_INVALID_TYPE_PARAMETERS;
8447 } else { 8447 } else {
8448 return CompileTimeErrorCode.NEW_WITH_INVALID_TYPE_PARAMETERS; 8448 return CompileTimeErrorCode.NEW_WITH_INVALID_TYPE_PARAMETERS;
8449 } 8449 }
8450 } 8450 }
8451 } 8451 }
8452 return StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS; 8452 return StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS;
8453 } 8453 }
8454 8454
8455 /** 8455 /**
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
8844 */ 8844 */
8845 void defineParameters(ExecutableElement functionElement) { 8845 void defineParameters(ExecutableElement functionElement) {
8846 Scope parameterScope = enclosingScope; 8846 Scope parameterScope = enclosingScope;
8847 if (functionElement.enclosingElement is ExecutableElement) { 8847 if (functionElement.enclosingElement is ExecutableElement) {
8848 String name = functionElement.name; 8848 String name = functionElement.name;
8849 if (name != null && !name.isEmpty) { 8849 if (name != null && !name.isEmpty) {
8850 parameterScope.define(functionElement); 8850 parameterScope.define(functionElement);
8851 } 8851 }
8852 } 8852 }
8853 for (ParameterElement parameter in functionElement.parameters) { 8853 for (ParameterElement parameter in functionElement.parameters) {
8854 if (!parameter.isInitializingFormal()) { 8854 if (!parameter.isInitializingFormal) {
8855 parameterScope.define(parameter); 8855 parameterScope.define(parameter);
8856 } 8856 }
8857 } 8857 }
8858 } 8858 }
8859 } 8859 }
8860 /** 8860 /**
8861 * Instances of the class `FunctionTypeScope` implement the scope defined by a f unction type 8861 * Instances of the class `FunctionTypeScope` implement the scope defined by a f unction type
8862 * alias. 8862 * alias.
8863 * @coverage dart.engine.resolver 8863 * @coverage dart.engine.resolver
8864 */ 8864 */
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
9127 * @param errorListener the listener that is to be informed when an error is e ncountered 9127 * @param errorListener the listener that is to be informed when an error is e ncountered
9128 */ 9128 */
9129 LibraryScope(LibraryElement definingLibrary, AnalysisErrorListener errorListen er) : super(new LibraryImportScope(definingLibrary, errorListener)) { 9129 LibraryScope(LibraryElement definingLibrary, AnalysisErrorListener errorListen er) : super(new LibraryImportScope(definingLibrary, errorListener)) {
9130 defineTopLevelNames(definingLibrary); 9130 defineTopLevelNames(definingLibrary);
9131 } 9131 }
9132 AnalysisError getErrorForDuplicate(Element existing, Element duplicate) { 9132 AnalysisError getErrorForDuplicate(Element existing, Element duplicate) {
9133 if (existing is PrefixElement) { 9133 if (existing is PrefixElement) {
9134 int offset = duplicate.nameOffset; 9134 int offset = duplicate.nameOffset;
9135 if (duplicate is PropertyAccessorElement) { 9135 if (duplicate is PropertyAccessorElement) {
9136 PropertyAccessorElement accessor = duplicate as PropertyAccessorElement; 9136 PropertyAccessorElement accessor = duplicate as PropertyAccessorElement;
9137 if (accessor.isSynthetic()) { 9137 if (accessor.isSynthetic) {
9138 offset = accessor.variable.nameOffset; 9138 offset = accessor.variable.nameOffset;
9139 } 9139 }
9140 } 9140 }
9141 return new AnalysisError.con2(source, offset, duplicate.displayName.length , CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER, [existing.displayN ame]); 9141 return new AnalysisError.con2(source, offset, duplicate.displayName.length , CompileTimeErrorCode.PREFIX_COLLIDES_WITH_TOP_LEVEL_MEMBER, [existing.displayN ame]);
9142 } 9142 }
9143 return super.getErrorForDuplicate(existing, duplicate); 9143 return super.getErrorForDuplicate(existing, duplicate);
9144 } 9144 }
9145 9145
9146 /** 9146 /**
9147 * Add to this scope all of the public top-level names that are defined in the given compilation 9147 * Add to this scope all of the public top-level names that are defined in the given compilation
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
9701 return null; 9701 return null;
9702 } 9702 }
9703 Object visitSwitchCase(SwitchCase node) { 9703 Object visitSwitchCase(SwitchCase node) {
9704 super.visitSwitchCase(node); 9704 super.visitSwitchCase(node);
9705 validate(node.expression, CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION) ; 9705 validate(node.expression, CompileTimeErrorCode.NON_CONSTANT_CASE_EXPRESSION) ;
9706 return null; 9706 return null;
9707 } 9707 }
9708 Object visitVariableDeclaration(VariableDeclaration node) { 9708 Object visitVariableDeclaration(VariableDeclaration node) {
9709 super.visitVariableDeclaration(node); 9709 super.visitVariableDeclaration(node);
9710 Expression initializer = node.initializer; 9710 Expression initializer = node.initializer;
9711 if (initializer != null && node.isConst()) { 9711 if (initializer != null && node.isConst) {
9712 VariableElementImpl element = node.element as VariableElementImpl; 9712 VariableElementImpl element = node.element as VariableElementImpl;
9713 EvaluationResultImpl result = element.evaluationResult; 9713 EvaluationResultImpl result = element.evaluationResult;
9714 if (result == null) { 9714 if (result == null) {
9715 result = validate(initializer, CompileTimeErrorCode.CONST_INITIALIZED_WI TH_NON_CONSTANT_VALUE); 9715 result = validate(initializer, CompileTimeErrorCode.CONST_INITIALIZED_WI TH_NON_CONSTANT_VALUE);
9716 element.evaluationResult = result; 9716 element.evaluationResult = result;
9717 } else if (result is ErrorResult) { 9717 } else if (result is ErrorResult) {
9718 reportErrors(result, CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CON STANT_VALUE); 9718 reportErrors(result, CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CON STANT_VALUE);
9719 } 9719 }
9720 } 9720 }
9721 return null; 9721 return null;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
9761 reportErrors(result, errorCode); 9761 reportErrors(result, errorCode);
9762 return result; 9762 return result;
9763 } 9763 }
9764 9764
9765 /** 9765 /**
9766 * Validate that if the passed instance creation is 'const' then all its argum ents are constant 9766 * Validate that if the passed instance creation is 'const' then all its argum ents are constant
9767 * expressions. 9767 * expressions.
9768 * @param node the instance creation evaluate 9768 * @param node the instance creation evaluate
9769 */ 9769 */
9770 void validateConstantArguments(InstanceCreationExpression node) { 9770 void validateConstantArguments(InstanceCreationExpression node) {
9771 if (!node.isConst()) { 9771 if (!node.isConst) {
9772 return; 9772 return;
9773 } 9773 }
9774 ArgumentList argumentList = node.argumentList; 9774 ArgumentList argumentList = node.argumentList;
9775 if (argumentList == null) { 9775 if (argumentList == null) {
9776 return; 9776 return;
9777 } 9777 }
9778 for (Expression argument in argumentList.arguments) { 9778 for (Expression argument in argumentList.arguments) {
9779 if (argument is NamedExpression) { 9779 if (argument is NamedExpression) {
9780 argument = ((argument as NamedExpression)).expression; 9780 argument = ((argument as NamedExpression)).expression;
9781 } 9781 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
9858 class ConstantVisitor_9 extends ConstantVisitor { 9858 class ConstantVisitor_9 extends ConstantVisitor {
9859 final ConstantVerifier ConstantVerifier_this; 9859 final ConstantVerifier ConstantVerifier_this;
9860 List<ParameterElement> parameterElements; 9860 List<ParameterElement> parameterElements;
9861 ConstantVisitor_9(this.ConstantVerifier_this, this.parameterElements) : super( ); 9861 ConstantVisitor_9(this.ConstantVerifier_this, this.parameterElements) : super( );
9862 EvaluationResultImpl visitSimpleIdentifier(SimpleIdentifier node) { 9862 EvaluationResultImpl visitSimpleIdentifier(SimpleIdentifier node) {
9863 Element element = node.element; 9863 Element element = node.element;
9864 for (ParameterElement parameterElement in parameterElements) { 9864 for (ParameterElement parameterElement in parameterElements) {
9865 if (identical(parameterElement, element) && parameterElement != null) { 9865 if (identical(parameterElement, element) && parameterElement != null) {
9866 Type2 type = parameterElement.type; 9866 Type2 type = parameterElement.type;
9867 if (type != null) { 9867 if (type != null) {
9868 if (type.isDynamic()) { 9868 if (type.isDynamic) {
9869 return ValidResult.RESULT_DYNAMIC; 9869 return ValidResult.RESULT_DYNAMIC;
9870 } 9870 }
9871 if (type.isSubtypeOf(ConstantVerifier_this._boolType)) { 9871 if (type.isSubtypeOf(ConstantVerifier_this._boolType)) {
9872 return ValidResult.RESULT_BOOL; 9872 return ValidResult.RESULT_BOOL;
9873 } 9873 }
9874 if (type.isSubtypeOf(ConstantVerifier_this._intType)) { 9874 if (type.isSubtypeOf(ConstantVerifier_this._intType)) {
9875 return ValidResult.RESULT_INT; 9875 return ValidResult.RESULT_INT;
9876 } 9876 }
9877 if (type.isSubtypeOf(ConstantVerifier_this._numType)) { 9877 if (type.isSubtypeOf(ConstantVerifier_this._numType)) {
9878 return ValidResult.RESULT_NUM; 9878 return ValidResult.RESULT_NUM;
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
10005 */ 10005 */
10006 Set<String> _namesForReferenceToDeclaredVariableInInitializer = new Set<String >(); 10006 Set<String> _namesForReferenceToDeclaredVariableInInitializer = new Set<String >();
10007 10007
10008 /** 10008 /**
10009 * A list of types used by the [CompileTimeErrorCode#EXTENDS_DISALLOWED_CLASS] and[CompileTimeErrorCode#IMPLEMENTS_DISALLOWED_CLASS] error codes. 10009 * A list of types used by the [CompileTimeErrorCode#EXTENDS_DISALLOWED_CLASS] and[CompileTimeErrorCode#IMPLEMENTS_DISALLOWED_CLASS] error codes.
10010 */ 10010 */
10011 List<InterfaceType> _DISALLOWED_TYPES_TO_EXTEND_OR_IMPLEMENT; 10011 List<InterfaceType> _DISALLOWED_TYPES_TO_EXTEND_OR_IMPLEMENT;
10012 ErrorVerifier(ErrorReporter errorReporter, LibraryElement currentLibrary, Type Provider typeProvider, InheritanceManager inheritanceManager) { 10012 ErrorVerifier(ErrorReporter errorReporter, LibraryElement currentLibrary, Type Provider typeProvider, InheritanceManager inheritanceManager) {
10013 this._errorReporter = errorReporter; 10013 this._errorReporter = errorReporter;
10014 this._currentLibrary = currentLibrary; 10014 this._currentLibrary = currentLibrary;
10015 this._isInSystemLibrary = currentLibrary.source.isInSystemLibrary(); 10015 this._isInSystemLibrary = currentLibrary.source.isInSystemLibrary;
10016 this._typeProvider = typeProvider; 10016 this._typeProvider = typeProvider;
10017 this._inheritanceManager = inheritanceManager; 10017 this._inheritanceManager = inheritanceManager;
10018 _strictMode = currentLibrary.context.analysisOptions.strictMode; 10018 _strictMode = currentLibrary.context.analysisOptions.strictMode;
10019 _isEnclosingConstructorConst = false; 10019 _isEnclosingConstructorConst = false;
10020 _isInCatchClause = false; 10020 _isInCatchClause = false;
10021 _dynamicType = typeProvider.dynamicType; 10021 _dynamicType = typeProvider.dynamicType;
10022 _DISALLOWED_TYPES_TO_EXTEND_OR_IMPLEMENT = <InterfaceType> [typeProvider.num Type, typeProvider.intType, typeProvider.doubleType, typeProvider.boolType, type Provider.stringType]; 10022 _DISALLOWED_TYPES_TO_EXTEND_OR_IMPLEMENT = <InterfaceType> [typeProvider.num Type, typeProvider.intType, typeProvider.doubleType, typeProvider.boolType, type Provider.stringType];
10023 } 10023 }
10024 Object visitArgumentDefinitionTest(ArgumentDefinitionTest node) { 10024 Object visitArgumentDefinitionTest(ArgumentDefinitionTest node) {
10025 checkForArgumentDefinitionTestNonParameter(node); 10025 checkForArgumentDefinitionTestNonParameter(node);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
10073 checkForNonAbstractClassInheritsAbstractMember(node); 10073 checkForNonAbstractClassInheritsAbstractMember(node);
10074 checkForInconsistentMethodInheritance(); 10074 checkForInconsistentMethodInheritance();
10075 checkForRecursiveInterfaceInheritance(_enclosingClass, new List<ClassE lement>()); 10075 checkForRecursiveInterfaceInheritance(_enclosingClass, new List<ClassE lement>());
10076 } 10076 }
10077 } 10077 }
10078 ClassElement classElement = node.element; 10078 ClassElement classElement = node.element;
10079 if (classElement != null) { 10079 if (classElement != null) {
10080 List<FieldElement> fieldElements = classElement.fields; 10080 List<FieldElement> fieldElements = classElement.fields;
10081 _initialFieldElementsMap = new Map<FieldElement, INIT_STATE>(); 10081 _initialFieldElementsMap = new Map<FieldElement, INIT_STATE>();
10082 for (FieldElement fieldElement in fieldElements) { 10082 for (FieldElement fieldElement in fieldElements) {
10083 if (!fieldElement.isSynthetic()) { 10083 if (!fieldElement.isSynthetic) {
10084 _initialFieldElementsMap[fieldElement] = fieldElement.initializer == null ? INIT_STATE.NOT_INIT : INIT_STATE.INIT_IN_DECLARATION; 10084 _initialFieldElementsMap[fieldElement] = fieldElement.initializer == null ? INIT_STATE.NOT_INIT : INIT_STATE.INIT_IN_DECLARATION;
10085 } 10085 }
10086 } 10086 }
10087 } 10087 }
10088 checkForFinalNotInitialized(node); 10088 checkForFinalNotInitialized(node);
10089 return super.visitClassDeclaration(node); 10089 return super.visitClassDeclaration(node);
10090 } finally { 10090 } finally {
10091 _initialFieldElementsMap = null; 10091 _initialFieldElementsMap = null;
10092 _enclosingClass = outerClass; 10092 _enclosingClass = outerClass;
10093 } 10093 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
10152 checkForExportInternalLibrary(node); 10152 checkForExportInternalLibrary(node);
10153 return super.visitExportDirective(node); 10153 return super.visitExportDirective(node);
10154 } 10154 }
10155 Object visitExpressionFunctionBody(ExpressionFunctionBody node) { 10155 Object visitExpressionFunctionBody(ExpressionFunctionBody node) {
10156 FunctionType functionType = _enclosingFunction == null ? null : _enclosingFu nction.type; 10156 FunctionType functionType = _enclosingFunction == null ? null : _enclosingFu nction.type;
10157 Type2 expectedReturnType = functionType == null ? DynamicTypeImpl.instance : functionType.returnType; 10157 Type2 expectedReturnType = functionType == null ? DynamicTypeImpl.instance : functionType.returnType;
10158 checkForReturnOfInvalidType(node.expression, expectedReturnType); 10158 checkForReturnOfInvalidType(node.expression, expectedReturnType);
10159 return super.visitExpressionFunctionBody(node); 10159 return super.visitExpressionFunctionBody(node);
10160 } 10160 }
10161 Object visitFieldDeclaration(FieldDeclaration node) { 10161 Object visitFieldDeclaration(FieldDeclaration node) {
10162 if (!node.isStatic()) { 10162 if (!node.isStatic) {
10163 VariableDeclarationList variables = node.fields; 10163 VariableDeclarationList variables = node.fields;
10164 if (variables.isConst()) { 10164 if (variables.isConst) {
10165 _errorReporter.reportError4(CompileTimeErrorCode.CONST_INSTANCE_FIELD, v ariables.keyword, []); 10165 _errorReporter.reportError4(CompileTimeErrorCode.CONST_INSTANCE_FIELD, v ariables.keyword, []);
10166 } 10166 }
10167 } 10167 }
10168 return super.visitFieldDeclaration(node); 10168 return super.visitFieldDeclaration(node);
10169 } 10169 }
10170 Object visitFieldFormalParameter(FieldFormalParameter node) { 10170 Object visitFieldFormalParameter(FieldFormalParameter node) {
10171 checkForConstFormalParameter(node); 10171 checkForConstFormalParameter(node);
10172 checkForFieldInitializingFormalRedirectingConstructor(node); 10172 checkForFieldInitializingFormalRedirectingConstructor(node);
10173 return super.visitFieldFormalParameter(node); 10173 return super.visitFieldFormalParameter(node);
10174 } 10174 }
10175 Object visitFunctionDeclaration(FunctionDeclaration node) { 10175 Object visitFunctionDeclaration(FunctionDeclaration node) {
10176 ExecutableElement outerFunction = _enclosingFunction; 10176 ExecutableElement outerFunction = _enclosingFunction;
10177 try { 10177 try {
10178 SimpleIdentifier identifier = node.name; 10178 SimpleIdentifier identifier = node.name;
10179 String methodName = ""; 10179 String methodName = "";
10180 if (identifier != null) { 10180 if (identifier != null) {
10181 methodName = identifier.name; 10181 methodName = identifier.name;
10182 } 10182 }
10183 _enclosingFunction = node.element; 10183 _enclosingFunction = node.element;
10184 if (node.isSetter() || node.isGetter()) { 10184 if (node.isSetter || node.isGetter) {
10185 checkForMismatchedAccessorTypes(node, methodName); 10185 checkForMismatchedAccessorTypes(node, methodName);
10186 if (node.isSetter()) { 10186 if (node.isSetter) {
10187 FunctionExpression functionExpression = node.functionExpression; 10187 FunctionExpression functionExpression = node.functionExpression;
10188 if (functionExpression != null) { 10188 if (functionExpression != null) {
10189 checkForWrongNumberOfParametersForSetter(node.name, functionExpressi on.parameters); 10189 checkForWrongNumberOfParametersForSetter(node.name, functionExpressi on.parameters);
10190 } 10190 }
10191 TypeName returnType = node.returnType; 10191 TypeName returnType = node.returnType;
10192 checkForNonVoidReturnTypeForSetter(returnType); 10192 checkForNonVoidReturnTypeForSetter(returnType);
10193 } 10193 }
10194 } 10194 }
10195 return super.visitFunctionDeclaration(node); 10195 return super.visitFunctionDeclaration(node);
10196 } finally { 10196 } finally {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
10228 checkForArgumentTypeNotAssignable2(node.index); 10228 checkForArgumentTypeNotAssignable2(node.index);
10229 return super.visitIndexExpression(node); 10229 return super.visitIndexExpression(node);
10230 } 10230 }
10231 Object visitInstanceCreationExpression(InstanceCreationExpression node) { 10231 Object visitInstanceCreationExpression(InstanceCreationExpression node) {
10232 ConstructorName constructorName = node.constructorName; 10232 ConstructorName constructorName = node.constructorName;
10233 TypeName typeName = constructorName.type; 10233 TypeName typeName = constructorName.type;
10234 Type2 type = typeName.type; 10234 Type2 type = typeName.type;
10235 if (type is InterfaceType) { 10235 if (type is InterfaceType) {
10236 InterfaceType interfaceType = type as InterfaceType; 10236 InterfaceType interfaceType = type as InterfaceType;
10237 checkForConstOrNewWithAbstractClass(node, typeName, interfaceType); 10237 checkForConstOrNewWithAbstractClass(node, typeName, interfaceType);
10238 if (node.isConst()) { 10238 if (node.isConst) {
10239 checkForConstWithNonConst(node); 10239 checkForConstWithNonConst(node);
10240 checkForConstWithUndefinedConstructor(node); 10240 checkForConstWithUndefinedConstructor(node);
10241 checkForConstWithTypeParameters(node); 10241 checkForConstWithTypeParameters(node);
10242 } else { 10242 } else {
10243 checkForNewWithUndefinedConstructor(node); 10243 checkForNewWithUndefinedConstructor(node);
10244 } 10244 }
10245 checkForTypeArgumentNotMatchingBounds(node, constructorName.element, typeN ame); 10245 checkForTypeArgumentNotMatchingBounds(node, constructorName.element, typeN ame);
10246 } 10246 }
10247 return super.visitInstanceCreationExpression(node); 10247 return super.visitInstanceCreationExpression(node);
10248 } 10248 }
(...skipping 25 matching lines...) Expand all
10274 } 10274 }
10275 Object visitMethodDeclaration(MethodDeclaration node) { 10275 Object visitMethodDeclaration(MethodDeclaration node) {
10276 ExecutableElement previousFunction = _enclosingFunction; 10276 ExecutableElement previousFunction = _enclosingFunction;
10277 try { 10277 try {
10278 _enclosingFunction = node.element; 10278 _enclosingFunction = node.element;
10279 SimpleIdentifier identifier = node.name; 10279 SimpleIdentifier identifier = node.name;
10280 String methoName = ""; 10280 String methoName = "";
10281 if (identifier != null) { 10281 if (identifier != null) {
10282 methoName = identifier.name; 10282 methoName = identifier.name;
10283 } 10283 }
10284 if (node.isSetter() || node.isGetter()) { 10284 if (node.isSetter || node.isGetter) {
10285 checkForMismatchedAccessorTypes(node, methoName); 10285 checkForMismatchedAccessorTypes(node, methoName);
10286 checkForConflictingInstanceGetterAndSuperclassMember(node); 10286 checkForConflictingInstanceGetterAndSuperclassMember(node);
10287 } 10287 }
10288 if (node.isGetter()) { 10288 if (node.isGetter) {
10289 checkForConflictingStaticGetterAndInstanceSetter(node); 10289 checkForConflictingStaticGetterAndInstanceSetter(node);
10290 } else if (node.isSetter()) { 10290 } else if (node.isSetter) {
10291 checkForWrongNumberOfParametersForSetter(node.name, node.parameters); 10291 checkForWrongNumberOfParametersForSetter(node.name, node.parameters);
10292 checkForNonVoidReturnTypeForSetter(node.returnType); 10292 checkForNonVoidReturnTypeForSetter(node.returnType);
10293 checkForConflictingStaticSetterAndInstanceMember(node); 10293 checkForConflictingStaticSetterAndInstanceMember(node);
10294 } else if (node.isOperator()) { 10294 } else if (node.isOperator) {
10295 checkForOptionalParameterInOperator(node); 10295 checkForOptionalParameterInOperator(node);
10296 checkForWrongNumberOfParametersForOperator(node); 10296 checkForWrongNumberOfParametersForOperator(node);
10297 checkForNonVoidReturnTypeForOperator(node); 10297 checkForNonVoidReturnTypeForOperator(node);
10298 } 10298 }
10299 checkForConcreteClassWithAbstractMember(node); 10299 checkForConcreteClassWithAbstractMember(node);
10300 checkForAllInvalidOverrideErrorCodes(node); 10300 checkForAllInvalidOverrideErrorCodes(node);
10301 return super.visitMethodDeclaration(node); 10301 return super.visitMethodDeclaration(node);
10302 } finally { 10302 } finally {
10303 _enclosingFunction = previousFunction; 10303 _enclosingFunction = previousFunction;
10304 } 10304 }
10305 } 10305 }
10306 Object visitMethodInvocation(MethodInvocation node) { 10306 Object visitMethodInvocation(MethodInvocation node) {
10307 checkForStaticAccessToInstanceMember(node.target, node.methodName); 10307 checkForStaticAccessToInstanceMember(node.target, node.methodName);
10308 return super.visitMethodInvocation(node); 10308 return super.visitMethodInvocation(node);
10309 } 10309 }
10310 Object visitNativeFunctionBody(NativeFunctionBody node) { 10310 Object visitNativeFunctionBody(NativeFunctionBody node) {
10311 checkForNativeFunctionBodyInNonSDKCode(node); 10311 checkForNativeFunctionBodyInNonSDKCode(node);
10312 return super.visitNativeFunctionBody(node); 10312 return super.visitNativeFunctionBody(node);
10313 } 10313 }
10314 Object visitPostfixExpression(PostfixExpression node) { 10314 Object visitPostfixExpression(PostfixExpression node) {
10315 checkForAssignmentToFinal2(node.operand); 10315 checkForAssignmentToFinal2(node.operand);
10316 return super.visitPostfixExpression(node); 10316 return super.visitPostfixExpression(node);
10317 } 10317 }
10318 Object visitPrefixedIdentifier(PrefixedIdentifier node) { 10318 Object visitPrefixedIdentifier(PrefixedIdentifier node) {
10319 checkForStaticAccessToInstanceMember(node.prefix, node.identifier); 10319 checkForStaticAccessToInstanceMember(node.prefix, node.identifier);
10320 return super.visitPrefixedIdentifier(node); 10320 return super.visitPrefixedIdentifier(node);
10321 } 10321 }
10322 Object visitPrefixExpression(PrefixExpression node) { 10322 Object visitPrefixExpression(PrefixExpression node) {
10323 if (node.operator.type.isIncrementOperator()) { 10323 if (node.operator.type.isIncrementOperator) {
10324 checkForAssignmentToFinal2(node.operand); 10324 checkForAssignmentToFinal2(node.operand);
10325 } 10325 }
10326 return super.visitPrefixExpression(node); 10326 return super.visitPrefixExpression(node);
10327 } 10327 }
10328 Object visitPropertyAccess(PropertyAccess node) { 10328 Object visitPropertyAccess(PropertyAccess node) {
10329 checkForStaticAccessToInstanceMember(node.target, node.propertyName); 10329 checkForStaticAccessToInstanceMember(node.target, node.propertyName);
10330 return super.visitPropertyAccess(node); 10330 return super.visitPropertyAccess(node);
10331 } 10331 }
10332 Object visitRedirectingConstructorInvocation(RedirectingConstructorInvocation node) { 10332 Object visitRedirectingConstructorInvocation(RedirectingConstructorInvocation node) {
10333 _isInConstructorInitializer = true; 10333 _isInConstructorInitializer = true;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
10434 FormalParameter parameter = formalParameter; 10434 FormalParameter parameter = formalParameter;
10435 if (parameter is DefaultFormalParameter) { 10435 if (parameter is DefaultFormalParameter) {
10436 parameter = ((parameter as DefaultFormalParameter)).parameter; 10436 parameter = ((parameter as DefaultFormalParameter)).parameter;
10437 } 10437 }
10438 if (parameter is FieldFormalParameter) { 10438 if (parameter is FieldFormalParameter) {
10439 FieldElement fieldElement = ((parameter.element as FieldFormalParameterE lementImpl)).field; 10439 FieldElement fieldElement = ((parameter.element as FieldFormalParameterE lementImpl)).field;
10440 INIT_STATE state = fieldElementsMap[fieldElement]; 10440 INIT_STATE state = fieldElementsMap[fieldElement];
10441 if (identical(state, INIT_STATE.NOT_INIT)) { 10441 if (identical(state, INIT_STATE.NOT_INIT)) {
10442 fieldElementsMap[fieldElement] = INIT_STATE.INIT_IN_FIELD_FORMAL; 10442 fieldElementsMap[fieldElement] = INIT_STATE.INIT_IN_FIELD_FORMAL;
10443 } else if (identical(state, INIT_STATE.INIT_IN_DECLARATION)) { 10443 } else if (identical(state, INIT_STATE.INIT_IN_DECLARATION)) {
10444 if (fieldElement.isFinal() || fieldElement.isConst()) { 10444 if (fieldElement.isFinal || fieldElement.isConst) {
10445 _errorReporter.reportError2(CompileTimeErrorCode.FINAL_INITIALIZED_I N_DECLARATION_AND_CONSTRUCTOR, formalParameter.identifier, [fieldElement.display Name]); 10445 _errorReporter.reportError2(CompileTimeErrorCode.FINAL_INITIALIZED_I N_DECLARATION_AND_CONSTRUCTOR, formalParameter.identifier, [fieldElement.display Name]);
10446 foundError = true; 10446 foundError = true;
10447 } 10447 }
10448 } else if (identical(state, INIT_STATE.INIT_IN_FIELD_FORMAL)) { 10448 } else if (identical(state, INIT_STATE.INIT_IN_FIELD_FORMAL)) {
10449 if (fieldElement.isFinal() || fieldElement.isConst()) { 10449 if (fieldElement.isFinal || fieldElement.isConst) {
10450 _errorReporter.reportError2(CompileTimeErrorCode.FINAL_INITIALIZED_M ULTIPLE_TIMES, formalParameter.identifier, [fieldElement.displayName]); 10450 _errorReporter.reportError2(CompileTimeErrorCode.FINAL_INITIALIZED_M ULTIPLE_TIMES, formalParameter.identifier, [fieldElement.displayName]);
10451 foundError = true; 10451 foundError = true;
10452 } 10452 }
10453 } 10453 }
10454 } 10454 }
10455 } 10455 }
10456 NodeList<ConstructorInitializer> initializers = node.initializers; 10456 NodeList<ConstructorInitializer> initializers = node.initializers;
10457 for (ConstructorInitializer constructorInitializer in initializers) { 10457 for (ConstructorInitializer constructorInitializer in initializers) {
10458 if (constructorInitializer is ConstructorFieldInitializer) { 10458 if (constructorInitializer is ConstructorFieldInitializer) {
10459 ConstructorFieldInitializer constructorFieldInitializer = constructorIni tializer as ConstructorFieldInitializer; 10459 ConstructorFieldInitializer constructorFieldInitializer = constructorIni tializer as ConstructorFieldInitializer;
10460 SimpleIdentifier fieldName = constructorFieldInitializer.fieldName; 10460 SimpleIdentifier fieldName = constructorFieldInitializer.fieldName;
10461 Element element = fieldName.element; 10461 Element element = fieldName.element;
10462 if (element is FieldElement) { 10462 if (element is FieldElement) {
10463 FieldElement fieldElement = element as FieldElement; 10463 FieldElement fieldElement = element as FieldElement;
10464 INIT_STATE state = fieldElementsMap[fieldElement]; 10464 INIT_STATE state = fieldElementsMap[fieldElement];
10465 if (identical(state, INIT_STATE.NOT_INIT)) { 10465 if (identical(state, INIT_STATE.NOT_INIT)) {
10466 fieldElementsMap[fieldElement] = INIT_STATE.INIT_IN_INITIALIZERS; 10466 fieldElementsMap[fieldElement] = INIT_STATE.INIT_IN_INITIALIZERS;
10467 } else if (identical(state, INIT_STATE.INIT_IN_DECLARATION)) { 10467 } else if (identical(state, INIT_STATE.INIT_IN_DECLARATION)) {
10468 if (fieldElement.isFinal() || fieldElement.isConst()) { 10468 if (fieldElement.isFinal || fieldElement.isConst) {
10469 _errorReporter.reportError2(CompileTimeErrorCode.FIELD_INITIALIZED _IN_INITIALIZER_AND_DECLARATION, fieldName, []); 10469 _errorReporter.reportError2(CompileTimeErrorCode.FIELD_INITIALIZED _IN_INITIALIZER_AND_DECLARATION, fieldName, []);
10470 foundError = true; 10470 foundError = true;
10471 } 10471 }
10472 } else if (identical(state, INIT_STATE.INIT_IN_FIELD_FORMAL)) { 10472 } else if (identical(state, INIT_STATE.INIT_IN_FIELD_FORMAL)) {
10473 _errorReporter.reportError2(CompileTimeErrorCode.FIELD_INITIALIZED_I N_PARAMETER_AND_INITIALIZER, fieldName, []); 10473 _errorReporter.reportError2(CompileTimeErrorCode.FIELD_INITIALIZED_I N_PARAMETER_AND_INITIALIZER, fieldName, []);
10474 foundError = true; 10474 foundError = true;
10475 } else if (identical(state, INIT_STATE.INIT_IN_INITIALIZERS)) { 10475 } else if (identical(state, INIT_STATE.INIT_IN_INITIALIZERS)) {
10476 _errorReporter.reportError2(CompileTimeErrorCode.FIELD_INITIALIZED_B Y_MULTIPLE_INITIALIZERS, fieldName, [fieldElement.displayName]); 10476 _errorReporter.reportError2(CompileTimeErrorCode.FIELD_INITIALIZED_B Y_MULTIPLE_INITIALIZERS, fieldName, [fieldElement.displayName]);
10477 foundError = true; 10477 foundError = true;
10478 } 10478 }
(...skipping 13 matching lines...) Expand all
10492 * @see CompileTimeErrorCode#INVALID_OVERRIDE_NAMED 10492 * @see CompileTimeErrorCode#INVALID_OVERRIDE_NAMED
10493 * @see StaticWarningCode#INVALID_GETTER_OVERRIDE_RETURN_TYPE 10493 * @see StaticWarningCode#INVALID_GETTER_OVERRIDE_RETURN_TYPE
10494 * @see StaticWarningCode#INVALID_METHOD_OVERRIDE_RETURN_TYPE 10494 * @see StaticWarningCode#INVALID_METHOD_OVERRIDE_RETURN_TYPE
10495 * @see StaticWarningCode#INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE 10495 * @see StaticWarningCode#INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE
10496 * @see StaticWarningCode#INVALID_SETTER_OVERRIDE_NORMAL_PARAM_TYPE 10496 * @see StaticWarningCode#INVALID_SETTER_OVERRIDE_NORMAL_PARAM_TYPE
10497 * @see StaticWarningCode#INVALID_METHOD_OVERRIDE_OPTIONAL_PARAM_TYPE 10497 * @see StaticWarningCode#INVALID_METHOD_OVERRIDE_OPTIONAL_PARAM_TYPE
10498 * @see StaticWarningCode#INVALID_METHOD_OVERRIDE_NAMED_PARAM_TYPE 10498 * @see StaticWarningCode#INVALID_METHOD_OVERRIDE_NAMED_PARAM_TYPE
10499 * @see StaticWarningCode#INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES 10499 * @see StaticWarningCode#INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES
10500 */ 10500 */
10501 bool checkForAllInvalidOverrideErrorCodes(MethodDeclaration node) { 10501 bool checkForAllInvalidOverrideErrorCodes(MethodDeclaration node) {
10502 if (_enclosingClass == null || node.isStatic() || node.body is NativeFunctio nBody) { 10502 if (_enclosingClass == null || node.isStatic || node.body is NativeFunctionB ody) {
10503 return false; 10503 return false;
10504 } 10504 }
10505 ExecutableElement executableElement = node.element; 10505 ExecutableElement executableElement = node.element;
10506 if (executableElement == null) { 10506 if (executableElement == null) {
10507 return false; 10507 return false;
10508 } 10508 }
10509 SimpleIdentifier methodName = node.name; 10509 SimpleIdentifier methodName = node.name;
10510 if (methodName.isSynthetic()) { 10510 if (methodName.isSynthetic) {
10511 return false; 10511 return false;
10512 } 10512 }
10513 String methodNameStr = methodName.name; 10513 String methodNameStr = methodName.name;
10514 ExecutableElement overriddenExecutable = _inheritanceManager.lookupInheritan ce(_enclosingClass, executableElement.name); 10514 ExecutableElement overriddenExecutable = _inheritanceManager.lookupInheritan ce(_enclosingClass, executableElement.name);
10515 if (overriddenExecutable == null) { 10515 if (overriddenExecutable == null) {
10516 if (!node.isGetter() && !node.isSetter() && !node.isOperator()) { 10516 if (!node.isGetter && !node.isSetter && !node.isOperator) {
10517 Set<ClassElement> visitedClasses = new Set<ClassElement>(); 10517 Set<ClassElement> visitedClasses = new Set<ClassElement>();
10518 InterfaceType superclassType = _enclosingClass.supertype; 10518 InterfaceType superclassType = _enclosingClass.supertype;
10519 ClassElement superclassElement = superclassType == null ? null : supercl assType.element; 10519 ClassElement superclassElement = superclassType == null ? null : supercl assType.element;
10520 while (superclassElement != null && !visitedClasses.contains(superclassE lement)) { 10520 while (superclassElement != null && !visitedClasses.contains(superclassE lement)) {
10521 javaSetAdd(visitedClasses, superclassElement); 10521 javaSetAdd(visitedClasses, superclassElement);
10522 List<FieldElement> fieldElts = superclassElement.fields; 10522 List<FieldElement> fieldElts = superclassElement.fields;
10523 for (FieldElement fieldElt in fieldElts) { 10523 for (FieldElement fieldElt in fieldElts) {
10524 if (fieldElt.name == methodNameStr && fieldElt.isStatic()) { 10524 if (fieldElt.name == methodNameStr && fieldElt.isStatic) {
10525 _errorReporter.reportError2(StaticWarningCode.INSTANCE_METHOD_NAME _COLLIDES_WITH_SUPERCLASS_STATIC, methodName, [methodNameStr, fieldElt.enclosing Element.displayName]); 10525 _errorReporter.reportError2(StaticWarningCode.INSTANCE_METHOD_NAME _COLLIDES_WITH_SUPERCLASS_STATIC, methodName, [methodNameStr, fieldElt.enclosing Element.displayName]);
10526 return true; 10526 return true;
10527 } 10527 }
10528 } 10528 }
10529 List<PropertyAccessorElement> propertyAccessorElts = superclassElement .accessors; 10529 List<PropertyAccessorElement> propertyAccessorElts = superclassElement .accessors;
10530 for (PropertyAccessorElement accessorElt in propertyAccessorElts) { 10530 for (PropertyAccessorElement accessorElt in propertyAccessorElts) {
10531 if (accessorElt.name == methodNameStr && accessorElt.isStatic()) { 10531 if (accessorElt.name == methodNameStr && accessorElt.isStatic) {
10532 _errorReporter.reportError2(StaticWarningCode.INSTANCE_METHOD_NAME _COLLIDES_WITH_SUPERCLASS_STATIC, methodName, [methodNameStr, accessorElt.enclos ingElement.displayName]); 10532 _errorReporter.reportError2(StaticWarningCode.INSTANCE_METHOD_NAME _COLLIDES_WITH_SUPERCLASS_STATIC, methodName, [methodNameStr, accessorElt.enclos ingElement.displayName]);
10533 return true; 10533 return true;
10534 } 10534 }
10535 } 10535 }
10536 List<MethodElement> methodElements = superclassElement.methods; 10536 List<MethodElement> methodElements = superclassElement.methods;
10537 for (MethodElement methodElement in methodElements) { 10537 for (MethodElement methodElement in methodElements) {
10538 if (methodElement.name == methodNameStr && methodElement.isStatic()) { 10538 if (methodElement.name == methodNameStr && methodElement.isStatic) {
10539 _errorReporter.reportError2(StaticWarningCode.INSTANCE_METHOD_NAME _COLLIDES_WITH_SUPERCLASS_STATIC, methodName, [methodNameStr, methodElement.encl osingElement.displayName]); 10539 _errorReporter.reportError2(StaticWarningCode.INSTANCE_METHOD_NAME _COLLIDES_WITH_SUPERCLASS_STATIC, methodName, [methodNameStr, methodElement.encl osingElement.displayName]);
10540 return true; 10540 return true;
10541 } 10541 }
10542 } 10542 }
10543 superclassType = superclassElement.supertype; 10543 superclassType = superclassElement.supertype;
10544 superclassElement = superclassType == null ? null : superclassType.ele ment; 10544 superclassElement = superclassType == null ? null : superclassType.ele ment;
10545 } 10545 }
10546 } 10546 }
10547 return false; 10547 return false;
10548 } 10548 }
(...skipping 23 matching lines...) Expand all
10572 Set<String> overridingParameterNameSet = overridingNamedPT.keys.toSet(); 10572 Set<String> overridingParameterNameSet = overridingNamedPT.keys.toSet();
10573 JavaIterator<String> overriddenParameterNameIterator = new JavaIterator(over riddenNamedPT.keys.toSet()); 10573 JavaIterator<String> overriddenParameterNameIterator = new JavaIterator(over riddenNamedPT.keys.toSet());
10574 while (overriddenParameterNameIterator.hasNext) { 10574 while (overriddenParameterNameIterator.hasNext) {
10575 String overriddenParamName = overriddenParameterNameIterator.next(); 10575 String overriddenParamName = overriddenParameterNameIterator.next();
10576 if (!overridingParameterNameSet.contains(overriddenParamName)) { 10576 if (!overridingParameterNameSet.contains(overriddenParamName)) {
10577 _errorReporter.reportError2(CompileTimeErrorCode.INVALID_OVERRIDE_NAMED, methodName, [overriddenParamName, overriddenExecutable.enclosingElement.display Name]); 10577 _errorReporter.reportError2(CompileTimeErrorCode.INVALID_OVERRIDE_NAMED, methodName, [overriddenParamName, overriddenExecutable.enclosingElement.display Name]);
10578 return true; 10578 return true;
10579 } 10579 }
10580 } 10580 }
10581 if (overriddenFTReturnType != VoidTypeImpl.instance && !overridingFTReturnTy pe.isAssignableTo(overriddenFTReturnType)) { 10581 if (overriddenFTReturnType != VoidTypeImpl.instance && !overridingFTReturnTy pe.isAssignableTo(overriddenFTReturnType)) {
10582 _errorReporter.reportError2(!node.isGetter() ? StaticWarningCode.INVALID_M ETHOD_OVERRIDE_RETURN_TYPE : StaticWarningCode.INVALID_GETTER_OVERRIDE_RETURN_TY PE, methodName, [overridingFTReturnType.displayName, overriddenFTReturnType.disp layName, overriddenExecutable.enclosingElement.displayName]); 10582 _errorReporter.reportError2(!node.isGetter ? StaticWarningCode.INVALID_MET HOD_OVERRIDE_RETURN_TYPE : StaticWarningCode.INVALID_GETTER_OVERRIDE_RETURN_TYPE , methodName, [overridingFTReturnType.displayName, overriddenFTReturnType.displa yName, overriddenExecutable.enclosingElement.displayName]);
10583 return true; 10583 return true;
10584 } 10584 }
10585 FormalParameterList formalParameterList = node.parameters; 10585 FormalParameterList formalParameterList = node.parameters;
10586 if (formalParameterList == null) { 10586 if (formalParameterList == null) {
10587 return false; 10587 return false;
10588 } 10588 }
10589 NodeList<FormalParameter> parameterNodeList = formalParameterList.parameters ; 10589 NodeList<FormalParameter> parameterNodeList = formalParameterList.parameters ;
10590 int parameterIndex = 0; 10590 int parameterIndex = 0;
10591 for (int i = 0; i < overridingNormalPT.length; i++) { 10591 for (int i = 0; i < overridingNormalPT.length; i++) {
10592 if (!overridingNormalPT[i].isAssignableTo(overriddenNormalPT[i])) { 10592 if (!overridingNormalPT[i].isAssignableTo(overriddenNormalPT[i])) {
10593 _errorReporter.reportError2(!node.isSetter() ? StaticWarningCode.INVALID _METHOD_OVERRIDE_NORMAL_PARAM_TYPE : StaticWarningCode.INVALID_SETTER_OVERRIDE_N ORMAL_PARAM_TYPE, parameterNodeList[parameterIndex], [overridingNormalPT[i].disp layName, overriddenNormalPT[i].displayName, overriddenExecutable.enclosingElemen t.displayName]); 10593 _errorReporter.reportError2(!node.isSetter ? StaticWarningCode.INVALID_M ETHOD_OVERRIDE_NORMAL_PARAM_TYPE : StaticWarningCode.INVALID_SETTER_OVERRIDE_NOR MAL_PARAM_TYPE, parameterNodeList[parameterIndex], [overridingNormalPT[i].displa yName, overriddenNormalPT[i].displayName, overriddenExecutable.enclosingElement. displayName]);
10594 return true; 10594 return true;
10595 } 10595 }
10596 parameterIndex++; 10596 parameterIndex++;
10597 } 10597 }
10598 for (int i = 0; i < overriddenPositionalPT.length; i++) { 10598 for (int i = 0; i < overriddenPositionalPT.length; i++) {
10599 if (!overridingPositionalPT[i].isAssignableTo(overriddenPositionalPT[i])) { 10599 if (!overridingPositionalPT[i].isAssignableTo(overriddenPositionalPT[i])) {
10600 _errorReporter.reportError2(StaticWarningCode.INVALID_METHOD_OVERRIDE_OP TIONAL_PARAM_TYPE, parameterNodeList[parameterIndex], [overridingPositionalPT[i] .displayName, overriddenPositionalPT[i].displayName, overriddenExecutable.enclos ingElement.displayName]); 10600 _errorReporter.reportError2(StaticWarningCode.INVALID_METHOD_OVERRIDE_OP TIONAL_PARAM_TYPE, parameterNodeList[parameterIndex], [overridingPositionalPT[i] .displayName, overriddenPositionalPT[i].displayName, overriddenExecutable.enclos ingElement.displayName]);
10601 return true; 10601 return true;
10602 } 10602 }
10603 parameterIndex++; 10603 parameterIndex++;
(...skipping 22 matching lines...) Expand all
10626 return true; 10626 return true;
10627 } 10627 }
10628 } 10628 }
10629 } 10629 }
10630 bool foundError = false; 10630 bool foundError = false;
10631 List<FormalParameter> formalParameters = new List<FormalParameter>(); 10631 List<FormalParameter> formalParameters = new List<FormalParameter>();
10632 List<ParameterElementImpl> parameterElts = new List<ParameterElementImpl>(); 10632 List<ParameterElementImpl> parameterElts = new List<ParameterElementImpl>();
10633 List<ParameterElementImpl> overriddenParameterElts = new List<ParameterEleme ntImpl>(); 10633 List<ParameterElementImpl> overriddenParameterElts = new List<ParameterEleme ntImpl>();
10634 List<ParameterElement> overriddenPEs = overriddenExecutable.parameters; 10634 List<ParameterElement> overriddenPEs = overriddenExecutable.parameters;
10635 for (FormalParameter formalParameter in parameterNodeList) { 10635 for (FormalParameter formalParameter in parameterNodeList) {
10636 if (formalParameter.kind.isOptional()) { 10636 if (formalParameter.kind.isOptional) {
10637 formalParameters.add(formalParameter); 10637 formalParameters.add(formalParameter);
10638 parameterElts.add((formalParameter.element as ParameterElementImpl)); 10638 parameterElts.add((formalParameter.element as ParameterElementImpl));
10639 } 10639 }
10640 } 10640 }
10641 for (ParameterElement parameterElt in overriddenPEs) { 10641 for (ParameterElement parameterElt in overriddenPEs) {
10642 if (parameterElt.parameterKind.isOptional()) { 10642 if (parameterElt.parameterKind.isOptional) {
10643 overriddenParameterElts.add((parameterElt as ParameterElementImpl)); 10643 overriddenParameterElts.add((parameterElt as ParameterElementImpl));
10644 } 10644 }
10645 } 10645 }
10646 if (parameterElts.length > 0) { 10646 if (parameterElts.length > 0) {
10647 if (identical(parameterElts[0].parameterKind, ParameterKind.NAMED)) { 10647 if (identical(parameterElts[0].parameterKind, ParameterKind.NAMED)) {
10648 for (int i = 0; i < parameterElts.length; i++) { 10648 for (int i = 0; i < parameterElts.length; i++) {
10649 ParameterElementImpl parameterElt = parameterElts[i]; 10649 ParameterElementImpl parameterElt = parameterElts[i];
10650 EvaluationResultImpl result = parameterElt.evaluationResult; 10650 EvaluationResultImpl result = parameterElt.evaluationResult;
10651 if (result == null || identical(result, ValidResult.RESULT_OBJECT)) { 10651 if (result == null || identical(result, ValidResult.RESULT_OBJECT)) {
10652 continue; 10652 continue;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
10770 * @param node the return statement to evaluate 10770 * @param node the return statement to evaluate
10771 * @return `true` if and only if an error code is generated on the passed node 10771 * @return `true` if and only if an error code is generated on the passed node
10772 * @see CompileTimeErrorCode#RETURN_IN_GENERATIVE_CONSTRUCTOR 10772 * @see CompileTimeErrorCode#RETURN_IN_GENERATIVE_CONSTRUCTOR
10773 * @see StaticWarningCode#RETURN_WITHOUT_VALUE 10773 * @see StaticWarningCode#RETURN_WITHOUT_VALUE
10774 * @see StaticTypeWarningCode#RETURN_OF_INVALID_TYPE 10774 * @see StaticTypeWarningCode#RETURN_OF_INVALID_TYPE
10775 */ 10775 */
10776 bool checkForAllReturnStatementErrorCodes(ReturnStatement node) { 10776 bool checkForAllReturnStatementErrorCodes(ReturnStatement node) {
10777 FunctionType functionType = _enclosingFunction == null ? null : _enclosingFu nction.type; 10777 FunctionType functionType = _enclosingFunction == null ? null : _enclosingFu nction.type;
10778 Type2 expectedReturnType = functionType == null ? DynamicTypeImpl.instance : functionType.returnType; 10778 Type2 expectedReturnType = functionType == null ? DynamicTypeImpl.instance : functionType.returnType;
10779 Expression returnExpression = node.expression; 10779 Expression returnExpression = node.expression;
10780 bool isGenerativeConstructor = _enclosingFunction is ConstructorElement && ! ((_enclosingFunction as ConstructorElement)).isFactory(); 10780 bool isGenerativeConstructor = _enclosingFunction is ConstructorElement && ! ((_enclosingFunction as ConstructorElement)).isFactory;
10781 if (isGenerativeConstructor) { 10781 if (isGenerativeConstructor) {
10782 if (returnExpression == null) { 10782 if (returnExpression == null) {
10783 return false; 10783 return false;
10784 } 10784 }
10785 _errorReporter.reportError2(CompileTimeErrorCode.RETURN_IN_GENERATIVE_CONS TRUCTOR, returnExpression, []); 10785 _errorReporter.reportError2(CompileTimeErrorCode.RETURN_IN_GENERATIVE_CONS TRUCTOR, returnExpression, []);
10786 return true; 10786 return true;
10787 } 10787 }
10788 if (returnExpression == null) { 10788 if (returnExpression == null) {
10789 if (VoidTypeImpl.instance.isAssignableTo(expectedReturnType)) { 10789 if (VoidTypeImpl.instance.isAssignableTo(expectedReturnType)) {
10790 return false; 10790 return false;
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
10918 bool checkForAssignmentToFinal2(Expression expression) { 10918 bool checkForAssignmentToFinal2(Expression expression) {
10919 Element element = null; 10919 Element element = null;
10920 if (expression is Identifier) { 10920 if (expression is Identifier) {
10921 element = ((expression as Identifier)).element; 10921 element = ((expression as Identifier)).element;
10922 } 10922 }
10923 if (expression is PropertyAccess) { 10923 if (expression is PropertyAccess) {
10924 element = ((expression as PropertyAccess)).propertyName.element; 10924 element = ((expression as PropertyAccess)).propertyName.element;
10925 } 10925 }
10926 if (element is VariableElement) { 10926 if (element is VariableElement) {
10927 VariableElement leftVar = element as VariableElement; 10927 VariableElement leftVar = element as VariableElement;
10928 if (leftVar.isFinal()) { 10928 if (leftVar.isFinal) {
10929 _errorReporter.reportError2(StaticWarningCode.ASSIGNMENT_TO_FINAL, expre ssion, []); 10929 _errorReporter.reportError2(StaticWarningCode.ASSIGNMENT_TO_FINAL, expre ssion, []);
10930 return true; 10930 return true;
10931 } 10931 }
10932 return false; 10932 return false;
10933 } 10933 }
10934 if (element is PropertyAccessorElement) { 10934 if (element is PropertyAccessorElement) {
10935 PropertyAccessorElement leftAccessor = element as PropertyAccessorElement; 10935 PropertyAccessorElement leftAccessor = element as PropertyAccessorElement;
10936 if (!leftAccessor.isSetter()) { 10936 if (!leftAccessor.isSetter) {
10937 _errorReporter.reportError2(StaticWarningCode.ASSIGNMENT_TO_FINAL, expre ssion, []); 10937 _errorReporter.reportError2(StaticWarningCode.ASSIGNMENT_TO_FINAL, expre ssion, []);
10938 return true; 10938 return true;
10939 } 10939 }
10940 return false; 10940 return false;
10941 } 10941 }
10942 return false; 10942 return false;
10943 } 10943 }
10944 10944
10945 /** 10945 /**
10946 * This verifies that the passed identifier is not a keyword, and generates th e passed error code 10946 * This verifies that the passed identifier is not a keyword, and generates th e passed error code
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
11066 } 11066 }
11067 11067
11068 /** 11068 /**
11069 * This verifies that the passed method declaration is abstract only if the en closing class is 11069 * This verifies that the passed method declaration is abstract only if the en closing class is
11070 * also abstract. 11070 * also abstract.
11071 * @param node the method declaration to evaluate 11071 * @param node the method declaration to evaluate
11072 * @return `true` if and only if an error code is generated on the passed node 11072 * @return `true` if and only if an error code is generated on the passed node
11073 * @see StaticWarningCode#CONCRETE_CLASS_WITH_ABSTRACT_MEMBER 11073 * @see StaticWarningCode#CONCRETE_CLASS_WITH_ABSTRACT_MEMBER
11074 */ 11074 */
11075 bool checkForConcreteClassWithAbstractMember(MethodDeclaration node) { 11075 bool checkForConcreteClassWithAbstractMember(MethodDeclaration node) {
11076 if (node.isAbstract() && _enclosingClass != null && !_enclosingClass.isAbstr act()) { 11076 if (node.isAbstract && _enclosingClass != null && !_enclosingClass.isAbstrac t) {
11077 SimpleIdentifier methodName = node.name; 11077 SimpleIdentifier methodName = node.name;
11078 _errorReporter.reportError2(StaticWarningCode.CONCRETE_CLASS_WITH_ABSTRACT _MEMBER, methodName, [methodName.name, _enclosingClass.displayName]); 11078 _errorReporter.reportError2(StaticWarningCode.CONCRETE_CLASS_WITH_ABSTRACT _MEMBER, methodName, [methodName.name, _enclosingClass.displayName]);
11079 return true; 11079 return true;
11080 } 11080 }
11081 return false; 11081 return false;
11082 } 11082 }
11083 11083
11084 /** 11084 /**
11085 * This verifies all possible conflicts of the constructor name with other con structors and 11085 * This verifies all possible conflicts of the constructor name with other con structors and
11086 * members of the same class. 11086 * members of the same class.
(...skipping 16 matching lines...) Expand all
11103 } 11103 }
11104 if (name == otherConstructor.name) { 11104 if (name == otherConstructor.name) {
11105 if (name == null || name.length == 0) { 11105 if (name == null || name.length == 0) {
11106 _errorReporter.reportError2(CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR _DEFAULT, node, []); 11106 _errorReporter.reportError2(CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR _DEFAULT, node, []);
11107 } else { 11107 } else {
11108 _errorReporter.reportError2(CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR _NAME, node, [name]); 11108 _errorReporter.reportError2(CompileTimeErrorCode.DUPLICATE_CONSTRUCTOR _NAME, node, [name]);
11109 } 11109 }
11110 return true; 11110 return true;
11111 } 11111 }
11112 } 11112 }
11113 if (constructorName != null && constructorElement != null && !constructorNam e.isSynthetic()) { 11113 if (constructorName != null && constructorElement != null && !constructorNam e.isSynthetic) {
11114 List<FieldElement> fields = classElement.fields; 11114 List<FieldElement> fields = classElement.fields;
11115 for (FieldElement field in fields) { 11115 for (FieldElement field in fields) {
11116 if (field.name == name) { 11116 if (field.name == name) {
11117 _errorReporter.reportError2(CompileTimeErrorCode.CONFLICTING_CONSTRUCT OR_NAME_AND_FIELD, node, [name]); 11117 _errorReporter.reportError2(CompileTimeErrorCode.CONFLICTING_CONSTRUCT OR_NAME_AND_FIELD, node, [name]);
11118 return true; 11118 return true;
11119 } 11119 }
11120 } 11120 }
11121 List<MethodElement> methods = classElement.methods; 11121 List<MethodElement> methods = classElement.methods;
11122 for (MethodElement method in methods) { 11122 for (MethodElement method in methods) {
11123 if (method.name == name) { 11123 if (method.name == name) {
11124 _errorReporter.reportError2(CompileTimeErrorCode.CONFLICTING_CONSTRUCT OR_NAME_AND_METHOD, node, [name]); 11124 _errorReporter.reportError2(CompileTimeErrorCode.CONFLICTING_CONSTRUCT OR_NAME_AND_METHOD, node, [name]);
11125 return true; 11125 return true;
11126 } 11126 }
11127 } 11127 }
11128 } 11128 }
11129 return false; 11129 return false;
11130 } 11130 }
11131 11131
11132 /** 11132 /**
11133 * This verifies that the superclass of the enclosing class does not declare a ccessible static 11133 * This verifies that the superclass of the enclosing class does not declare a ccessible static
11134 * member with the same name as the passed instance getter/setter method decla ration. 11134 * member with the same name as the passed instance getter/setter method decla ration.
11135 * @param node the method declaration to evaluate 11135 * @param node the method declaration to evaluate
11136 * @return `true` if and only if an error code is generated on the passed node 11136 * @return `true` if and only if an error code is generated on the passed node
11137 * @see StaticWarningCode#CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER 11137 * @see StaticWarningCode#CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER
11138 * @see StaticWarningCode#CONFLICTING_INSTANCE_SETTER_AND_SUPERCLASS_MEMBER 11138 * @see StaticWarningCode#CONFLICTING_INSTANCE_SETTER_AND_SUPERCLASS_MEMBER
11139 */ 11139 */
11140 bool checkForConflictingInstanceGetterAndSuperclassMember(MethodDeclaration no de) { 11140 bool checkForConflictingInstanceGetterAndSuperclassMember(MethodDeclaration no de) {
11141 if (node.isStatic()) { 11141 if (node.isStatic) {
11142 return false; 11142 return false;
11143 } 11143 }
11144 SimpleIdentifier nameNode = node.name; 11144 SimpleIdentifier nameNode = node.name;
11145 if (nameNode == null) { 11145 if (nameNode == null) {
11146 return false; 11146 return false;
11147 } 11147 }
11148 String name = nameNode.name; 11148 String name = nameNode.name;
11149 if (_enclosingClass == null) { 11149 if (_enclosingClass == null) {
11150 return false; 11150 return false;
11151 } 11151 }
11152 InterfaceType enclosingType = _enclosingClass.type; 11152 InterfaceType enclosingType = _enclosingClass.type;
11153 ExecutableElement superElement; 11153 ExecutableElement superElement;
11154 superElement = enclosingType.lookUpGetterInSuperclass(name, _currentLibrary) ; 11154 superElement = enclosingType.lookUpGetterInSuperclass(name, _currentLibrary) ;
11155 if (superElement == null) { 11155 if (superElement == null) {
11156 superElement = enclosingType.lookUpSetterInSuperclass(name, _currentLibrar y); 11156 superElement = enclosingType.lookUpSetterInSuperclass(name, _currentLibrar y);
11157 } 11157 }
11158 if (superElement == null) { 11158 if (superElement == null) {
11159 superElement = enclosingType.lookUpMethodInSuperclass(name, _currentLibrar y); 11159 superElement = enclosingType.lookUpMethodInSuperclass(name, _currentLibrar y);
11160 } 11160 }
11161 if (superElement == null) { 11161 if (superElement == null) {
11162 return false; 11162 return false;
11163 } 11163 }
11164 if (!superElement.isStatic()) { 11164 if (!superElement.isStatic) {
11165 return false; 11165 return false;
11166 } 11166 }
11167 ClassElement superElementClass = superElement.enclosingElement as ClassEleme nt; 11167 ClassElement superElementClass = superElement.enclosingElement as ClassEleme nt;
11168 InterfaceType superElementType = superElementClass.type; 11168 InterfaceType superElementType = superElementClass.type;
11169 if (node.isGetter()) { 11169 if (node.isGetter) {
11170 _errorReporter.reportError2(StaticWarningCode.CONFLICTING_INSTANCE_GETTER_ AND_SUPERCLASS_MEMBER, nameNode, [superElementType.displayName]); 11170 _errorReporter.reportError2(StaticWarningCode.CONFLICTING_INSTANCE_GETTER_ AND_SUPERCLASS_MEMBER, nameNode, [superElementType.displayName]);
11171 } else { 11171 } else {
11172 _errorReporter.reportError2(StaticWarningCode.CONFLICTING_INSTANCE_SETTER_ AND_SUPERCLASS_MEMBER, nameNode, [superElementType.displayName]); 11172 _errorReporter.reportError2(StaticWarningCode.CONFLICTING_INSTANCE_SETTER_ AND_SUPERCLASS_MEMBER, nameNode, [superElementType.displayName]);
11173 } 11173 }
11174 return true; 11174 return true;
11175 } 11175 }
11176 11176
11177 /** 11177 /**
11178 * This verifies that the enclosing class does not have an instance member wit h the same name as 11178 * This verifies that the enclosing class does not have an instance member wit h the same name as
11179 * the passed static getter method declaration. 11179 * the passed static getter method declaration.
11180 * @param node the method declaration to evaluate 11180 * @param node the method declaration to evaluate
11181 * @return `true` if and only if an error code is generated on the passed node 11181 * @return `true` if and only if an error code is generated on the passed node
11182 * @see StaticWarningCode#CONFLICTING_STATIC_GETTER_AND_INSTANCE_SETTER 11182 * @see StaticWarningCode#CONFLICTING_STATIC_GETTER_AND_INSTANCE_SETTER
11183 */ 11183 */
11184 bool checkForConflictingStaticGetterAndInstanceSetter(MethodDeclaration node) { 11184 bool checkForConflictingStaticGetterAndInstanceSetter(MethodDeclaration node) {
11185 if (!node.isStatic()) { 11185 if (!node.isStatic) {
11186 return false; 11186 return false;
11187 } 11187 }
11188 SimpleIdentifier nameNode = node.name; 11188 SimpleIdentifier nameNode = node.name;
11189 if (nameNode == null) { 11189 if (nameNode == null) {
11190 return false; 11190 return false;
11191 } 11191 }
11192 String name = nameNode.name; 11192 String name = nameNode.name;
11193 if (_enclosingClass == null) { 11193 if (_enclosingClass == null) {
11194 return false; 11194 return false;
11195 } 11195 }
11196 InterfaceType enclosingType = _enclosingClass.type; 11196 InterfaceType enclosingType = _enclosingClass.type;
11197 ExecutableElement setter = enclosingType.lookUpSetter(name, _currentLibrary) ; 11197 ExecutableElement setter = enclosingType.lookUpSetter(name, _currentLibrary) ;
11198 if (setter == null) { 11198 if (setter == null) {
11199 return false; 11199 return false;
11200 } 11200 }
11201 if (setter.isStatic()) { 11201 if (setter.isStatic) {
11202 return false; 11202 return false;
11203 } 11203 }
11204 ClassElement setterClass = setter.enclosingElement as ClassElement; 11204 ClassElement setterClass = setter.enclosingElement as ClassElement;
11205 InterfaceType setterType = setterClass.type; 11205 InterfaceType setterType = setterClass.type;
11206 _errorReporter.reportError2(StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_ INSTANCE_SETTER, nameNode, [setterType.displayName]); 11206 _errorReporter.reportError2(StaticWarningCode.CONFLICTING_STATIC_GETTER_AND_ INSTANCE_SETTER, nameNode, [setterType.displayName]);
11207 return true; 11207 return true;
11208 } 11208 }
11209 11209
11210 /** 11210 /**
11211 * This verifies that the enclosing class does not have an instance member wit h the same name as 11211 * This verifies that the enclosing class does not have an instance member wit h the same name as
11212 * the passed static getter method declaration. 11212 * the passed static getter method declaration.
11213 * @param node the method declaration to evaluate 11213 * @param node the method declaration to evaluate
11214 * @return `true` if and only if an error code is generated on the passed node 11214 * @return `true` if and only if an error code is generated on the passed node
11215 * @see StaticWarningCode#CONFLICTING_STATIC_SETTER_AND_INSTANCE_MEMBER 11215 * @see StaticWarningCode#CONFLICTING_STATIC_SETTER_AND_INSTANCE_MEMBER
11216 */ 11216 */
11217 bool checkForConflictingStaticSetterAndInstanceMember(MethodDeclaration node) { 11217 bool checkForConflictingStaticSetterAndInstanceMember(MethodDeclaration node) {
11218 if (!node.isStatic()) { 11218 if (!node.isStatic) {
11219 return false; 11219 return false;
11220 } 11220 }
11221 SimpleIdentifier nameNode = node.name; 11221 SimpleIdentifier nameNode = node.name;
11222 if (nameNode == null) { 11222 if (nameNode == null) {
11223 return false; 11223 return false;
11224 } 11224 }
11225 String name = nameNode.name; 11225 String name = nameNode.name;
11226 if (_enclosingClass == null) { 11226 if (_enclosingClass == null) {
11227 return false; 11227 return false;
11228 } 11228 }
11229 InterfaceType enclosingType = _enclosingClass.type; 11229 InterfaceType enclosingType = _enclosingClass.type;
11230 ExecutableElement member; 11230 ExecutableElement member;
11231 member = enclosingType.lookUpMethod(name, _currentLibrary); 11231 member = enclosingType.lookUpMethod(name, _currentLibrary);
11232 if (member == null) { 11232 if (member == null) {
11233 member = enclosingType.lookUpGetter(name, _currentLibrary); 11233 member = enclosingType.lookUpGetter(name, _currentLibrary);
11234 } 11234 }
11235 if (member == null) { 11235 if (member == null) {
11236 member = enclosingType.lookUpSetter(name, _currentLibrary); 11236 member = enclosingType.lookUpSetter(name, _currentLibrary);
11237 } 11237 }
11238 if (member == null) { 11238 if (member == null) {
11239 return false; 11239 return false;
11240 } 11240 }
11241 if (member.isStatic()) { 11241 if (member.isStatic) {
11242 return false; 11242 return false;
11243 } 11243 }
11244 ClassElement memberClass = member.enclosingElement as ClassElement; 11244 ClassElement memberClass = member.enclosingElement as ClassElement;
11245 InterfaceType memberType = memberClass.type; 11245 InterfaceType memberType = memberClass.type;
11246 _errorReporter.reportError2(StaticWarningCode.CONFLICTING_STATIC_SETTER_AND_ INSTANCE_MEMBER, nameNode, [memberType.displayName]); 11246 _errorReporter.reportError2(StaticWarningCode.CONFLICTING_STATIC_SETTER_AND_ INSTANCE_MEMBER, nameNode, [memberType.displayName]);
11247 return true; 11247 return true;
11248 } 11248 }
11249 11249
11250 /** 11250 /**
11251 * This verifies that the passed constructor declaration is 'const' then there are no non-final 11251 * This verifies that the passed constructor declaration is 'const' then there are no non-final
(...skipping 30 matching lines...) Expand all
11282 return false; 11282 return false;
11283 } 11283 }
11284 11284
11285 /** 11285 /**
11286 * This verifies that the passed normal formal parameter is not 'const'. 11286 * This verifies that the passed normal formal parameter is not 'const'.
11287 * @param node the normal formal parameter to evaluate 11287 * @param node the normal formal parameter to evaluate
11288 * @return `true` if and only if an error code is generated on the passed node 11288 * @return `true` if and only if an error code is generated on the passed node
11289 * @see CompileTimeErrorCode#CONST_FORMAL_PARAMETER 11289 * @see CompileTimeErrorCode#CONST_FORMAL_PARAMETER
11290 */ 11290 */
11291 bool checkForConstFormalParameter(NormalFormalParameter node) { 11291 bool checkForConstFormalParameter(NormalFormalParameter node) {
11292 if (node.isConst()) { 11292 if (node.isConst) {
11293 _errorReporter.reportError2(CompileTimeErrorCode.CONST_FORMAL_PARAMETER, n ode, []); 11293 _errorReporter.reportError2(CompileTimeErrorCode.CONST_FORMAL_PARAMETER, n ode, []);
11294 return true; 11294 return true;
11295 } 11295 }
11296 return false; 11296 return false;
11297 } 11297 }
11298 11298
11299 /** 11299 /**
11300 * This verifies that the passed instance creation expression is not being inv oked on an abstract 11300 * This verifies that the passed instance creation expression is not being inv oked on an abstract
11301 * class. 11301 * class.
11302 * @param node the instance creation expression to evaluate 11302 * @param node the instance creation expression to evaluate
11303 * @param typeName the [TypeName] of the [ConstructorName] from the[InstanceCr eationExpression], this is the AST node that the error is attached to 11303 * @param typeName the [TypeName] of the [ConstructorName] from the[InstanceCr eationExpression], this is the AST node that the error is attached to
11304 * @param type the type being constructed with this [InstanceCreationExpressio n] 11304 * @param type the type being constructed with this [InstanceCreationExpressio n]
11305 * @return `true` if and only if an error code is generated on the passed node 11305 * @return `true` if and only if an error code is generated on the passed node
11306 * @see StaticWarningCode#CONST_WITH_ABSTRACT_CLASS 11306 * @see StaticWarningCode#CONST_WITH_ABSTRACT_CLASS
11307 * @see StaticWarningCode#NEW_WITH_ABSTRACT_CLASS 11307 * @see StaticWarningCode#NEW_WITH_ABSTRACT_CLASS
11308 */ 11308 */
11309 bool checkForConstOrNewWithAbstractClass(InstanceCreationExpression node, Type Name typeName, InterfaceType type) { 11309 bool checkForConstOrNewWithAbstractClass(InstanceCreationExpression node, Type Name typeName, InterfaceType type) {
11310 if (type.element.isAbstract()) { 11310 if (type.element.isAbstract) {
11311 ConstructorElement element = node.element; 11311 ConstructorElement element = node.element;
11312 if (element != null && !element.isFactory()) { 11312 if (element != null && !element.isFactory) {
11313 if (identical(((node.keyword as sc.KeywordToken)).keyword, sc.Keyword.CO NST)) { 11313 if (identical(((node.keyword as sc.KeywordToken)).keyword, sc.Keyword.CO NST)) {
11314 _errorReporter.reportError2(StaticWarningCode.CONST_WITH_ABSTRACT_CLAS S, typeName, []); 11314 _errorReporter.reportError2(StaticWarningCode.CONST_WITH_ABSTRACT_CLAS S, typeName, []);
11315 } else { 11315 } else {
11316 _errorReporter.reportError2(StaticWarningCode.NEW_WITH_ABSTRACT_CLASS, typeName, []); 11316 _errorReporter.reportError2(StaticWarningCode.NEW_WITH_ABSTRACT_CLASS, typeName, []);
11317 } 11317 }
11318 return true; 11318 return true;
11319 } 11319 }
11320 } 11320 }
11321 return false; 11321 return false;
11322 } 11322 }
11323 11323
11324 /** 11324 /**
11325 * This verifies that the passed 'const' instance creation expression is not b eing invoked on a 11325 * This verifies that the passed 'const' instance creation expression is not b eing invoked on a
11326 * constructor that is not 'const'. 11326 * constructor that is not 'const'.
11327 * 11327 *
11328 * This method assumes that the instance creation was tested to be 'const' bef ore being called. 11328 * This method assumes that the instance creation was tested to be 'const' bef ore being called.
11329 * @param node the instance creation expression to evaluate 11329 * @param node the instance creation expression to evaluate
11330 * @return `true` if and only if an error code is generated on the passed node 11330 * @return `true` if and only if an error code is generated on the passed node
11331 * @see CompileTimeErrorCode#CONST_WITH_NON_CONST 11331 * @see CompileTimeErrorCode#CONST_WITH_NON_CONST
11332 */ 11332 */
11333 bool checkForConstWithNonConst(InstanceCreationExpression node) { 11333 bool checkForConstWithNonConst(InstanceCreationExpression node) {
11334 ConstructorElement constructorElement = node.element; 11334 ConstructorElement constructorElement = node.element;
11335 if (constructorElement != null && !constructorElement.isConst()) { 11335 if (constructorElement != null && !constructorElement.isConst) {
11336 _errorReporter.reportError2(CompileTimeErrorCode.CONST_WITH_NON_CONST, nod e, []); 11336 _errorReporter.reportError2(CompileTimeErrorCode.CONST_WITH_NON_CONST, nod e, []);
11337 return true; 11337 return true;
11338 } 11338 }
11339 return false; 11339 return false;
11340 } 11340 }
11341 11341
11342 /** 11342 /**
11343 * This verifies that the passed 'const' instance creation expression does not reference any type 11343 * This verifies that the passed 'const' instance creation expression does not reference any type
11344 * parameters. 11344 * parameters.
11345 * 11345 *
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
11483 if (element is! ExportElement) { 11483 if (element is! ExportElement) {
11484 return false; 11484 return false;
11485 } 11485 }
11486 ExportElement exportElement = element as ExportElement; 11486 ExportElement exportElement = element as ExportElement;
11487 DartSdk sdk = _currentLibrary.context.sourceFactory.dartSdk; 11487 DartSdk sdk = _currentLibrary.context.sourceFactory.dartSdk;
11488 String uri = exportElement.uri; 11488 String uri = exportElement.uri;
11489 SdkLibrary sdkLibrary = sdk.getSdkLibrary(uri); 11489 SdkLibrary sdkLibrary = sdk.getSdkLibrary(uri);
11490 if (sdkLibrary == null) { 11490 if (sdkLibrary == null) {
11491 return false; 11491 return false;
11492 } 11492 }
11493 if (!sdkLibrary.isInternal()) { 11493 if (!sdkLibrary.isInternal) {
11494 return false; 11494 return false;
11495 } 11495 }
11496 _errorReporter.reportError2(CompileTimeErrorCode.EXPORT_INTERNAL_LIBRARY, no de, [node.uri]); 11496 _errorReporter.reportError2(CompileTimeErrorCode.EXPORT_INTERNAL_LIBRARY, no de, [node.uri]);
11497 return true; 11497 return true;
11498 } 11498 }
11499 11499
11500 /** 11500 /**
11501 * This verifies that the passed extends clause does not extend classes such a s num or String. 11501 * This verifies that the passed extends clause does not extend classes such a s num or String.
11502 * @param node the extends clause to test 11502 * @param node the extends clause to test
11503 * @return `true` if and only if an error code is generated on the passed node 11503 * @return `true` if and only if an error code is generated on the passed node
(...skipping 10 matching lines...) Expand all
11514 * This verifies that the passed type name does not extend or implement classe s such as 'num' or 11514 * This verifies that the passed type name does not extend or implement classe s such as 'num' or
11515 * 'String'. 11515 * 'String'.
11516 * @param node the type name to test 11516 * @param node the type name to test
11517 * @return `true` if and only if an error code is generated on the passed node 11517 * @return `true` if and only if an error code is generated on the passed node
11518 * @see #checkForExtendsDisallowedClass(ExtendsClause) 11518 * @see #checkForExtendsDisallowedClass(ExtendsClause)
11519 * @see #checkForImplementsDisallowedClass(ImplementsClause) 11519 * @see #checkForImplementsDisallowedClass(ImplementsClause)
11520 * @see CompileTimeErrorCode#EXTENDS_DISALLOWED_CLASS 11520 * @see CompileTimeErrorCode#EXTENDS_DISALLOWED_CLASS
11521 * @see CompileTimeErrorCode#IMPLEMENTS_DISALLOWED_CLASS 11521 * @see CompileTimeErrorCode#IMPLEMENTS_DISALLOWED_CLASS
11522 */ 11522 */
11523 bool checkForExtendsOrImplementsDisallowedClass(TypeName typeName, ErrorCode e rrorCode) { 11523 bool checkForExtendsOrImplementsDisallowedClass(TypeName typeName, ErrorCode e rrorCode) {
11524 if (typeName.isSynthetic()) { 11524 if (typeName.isSynthetic) {
11525 return false; 11525 return false;
11526 } 11526 }
11527 Type2 superType = typeName.type; 11527 Type2 superType = typeName.type;
11528 for (InterfaceType disallowedType in _DISALLOWED_TYPES_TO_EXTEND_OR_IMPLEMEN T) { 11528 for (InterfaceType disallowedType in _DISALLOWED_TYPES_TO_EXTEND_OR_IMPLEMEN T) {
11529 if (superType != null && superType == disallowedType) { 11529 if (superType != null && superType == disallowedType) {
11530 if (superType == _typeProvider.numType) { 11530 if (superType == _typeProvider.numType) {
11531 ASTNode grandParent = typeName.parent.parent; 11531 ASTNode grandParent = typeName.parent.parent;
11532 if (grandParent is ClassDeclaration) { 11532 if (grandParent is ClassDeclaration) {
11533 ClassElement classElement = ((grandParent as ClassDeclaration)).elem ent; 11533 ClassElement classElement = ((grandParent as ClassDeclaration)).elem ent;
11534 Type2 classType = classElement.type; 11534 Type2 classType = classElement.type;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
11641 11641
11642 /** 11642 /**
11643 * This verifies that the passed variable declaration list has only initialize d variables if the 11643 * This verifies that the passed variable declaration list has only initialize d variables if the
11644 * list is final or const. This method is called by[checkForFinalNotInitialize d],[visitTopLevelVariableDeclaration] and[visitVariableDeclarationStatement]. 11644 * list is final or const. This method is called by[checkForFinalNotInitialize d],[visitTopLevelVariableDeclaration] and[visitVariableDeclarationStatement].
11645 * @param node the class declaration to test 11645 * @param node the class declaration to test
11646 * @return `true` if and only if an error code is generated on the passed node 11646 * @return `true` if and only if an error code is generated on the passed node
11647 * @see CompileTimeErrorCode#FINAL_NOT_INITIALIZED 11647 * @see CompileTimeErrorCode#FINAL_NOT_INITIALIZED
11648 */ 11648 */
11649 bool checkForFinalNotInitialized2(VariableDeclarationList node) { 11649 bool checkForFinalNotInitialized2(VariableDeclarationList node) {
11650 bool foundError = false; 11650 bool foundError = false;
11651 if (!node.isSynthetic() && (node.isConst() || node.isFinal())) { 11651 if (!node.isSynthetic && (node.isConst || node.isFinal)) {
11652 NodeList<VariableDeclaration> variables = node.variables; 11652 NodeList<VariableDeclaration> variables = node.variables;
11653 for (VariableDeclaration variable in variables) { 11653 for (VariableDeclaration variable in variables) {
11654 if (variable.initializer == null) { 11654 if (variable.initializer == null) {
11655 _errorReporter.reportError2(StaticWarningCode.FINAL_NOT_INITIALIZED, v ariable, [variable.name.name]); 11655 _errorReporter.reportError2(StaticWarningCode.FINAL_NOT_INITIALIZED, v ariable, [variable.name.name]);
11656 foundError = true; 11656 foundError = true;
11657 } 11657 }
11658 } 11658 }
11659 } 11659 }
11660 return foundError; 11660 return foundError;
11661 } 11661 }
(...skipping 25 matching lines...) Expand all
11687 */ 11687 */
11688 bool checkForImplicitThisReferenceInInitializer(SimpleIdentifier node) { 11688 bool checkForImplicitThisReferenceInInitializer(SimpleIdentifier node) {
11689 if (!_isInConstructorInitializer) { 11689 if (!_isInConstructorInitializer) {
11690 return false; 11690 return false;
11691 } 11691 }
11692 Element element = node.element; 11692 Element element = node.element;
11693 if (!(element is MethodElement || element is PropertyAccessorElement)) { 11693 if (!(element is MethodElement || element is PropertyAccessorElement)) {
11694 return false; 11694 return false;
11695 } 11695 }
11696 ExecutableElement executableElement = element as ExecutableElement; 11696 ExecutableElement executableElement = element as ExecutableElement;
11697 if (executableElement.isStatic()) { 11697 if (executableElement.isStatic) {
11698 return false; 11698 return false;
11699 } 11699 }
11700 Element enclosingElement = element.enclosingElement; 11700 Element enclosingElement = element.enclosingElement;
11701 if (enclosingElement is! ClassElement) { 11701 if (enclosingElement is! ClassElement) {
11702 return false; 11702 return false;
11703 } 11703 }
11704 ASTNode parent = node.parent; 11704 ASTNode parent = node.parent;
11705 if (parent is MethodInvocation) { 11705 if (parent is MethodInvocation) {
11706 MethodInvocation invocation = parent as MethodInvocation; 11706 MethodInvocation invocation = parent as MethodInvocation;
11707 if (identical(invocation.methodName, node) && invocation.realTarget != nul l) { 11707 if (identical(invocation.methodName, node) && invocation.realTarget != nul l) {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
11770 if (element is! ImportElement) { 11770 if (element is! ImportElement) {
11771 return false; 11771 return false;
11772 } 11772 }
11773 ImportElement importElement = element as ImportElement; 11773 ImportElement importElement = element as ImportElement;
11774 DartSdk sdk = _currentLibrary.context.sourceFactory.dartSdk; 11774 DartSdk sdk = _currentLibrary.context.sourceFactory.dartSdk;
11775 String uri = importElement.uri; 11775 String uri = importElement.uri;
11776 SdkLibrary sdkLibrary = sdk.getSdkLibrary(uri); 11776 SdkLibrary sdkLibrary = sdk.getSdkLibrary(uri);
11777 if (sdkLibrary == null) { 11777 if (sdkLibrary == null) {
11778 return false; 11778 return false;
11779 } 11779 }
11780 if (!sdkLibrary.isInternal()) { 11780 if (!sdkLibrary.isInternal) {
11781 return false; 11781 return false;
11782 } 11782 }
11783 _errorReporter.reportError2(CompileTimeErrorCode.IMPORT_INTERNAL_LIBRARY, no de, [node.uri]); 11783 _errorReporter.reportError2(CompileTimeErrorCode.IMPORT_INTERNAL_LIBRARY, no de, [node.uri]);
11784 return true; 11784 return true;
11785 } 11785 }
11786 11786
11787 /** 11787 /**
11788 * This verifies that the passed switch statement case expressions all have th e same type. 11788 * This verifies that the passed switch statement case expressions all have th e same type.
11789 * @param node the switch statement to evaluate 11789 * @param node the switch statement to evaluate
11790 * @return `true` if and only if an error code is generated on the passed node 11790 * @return `true` if and only if an error code is generated on the passed node
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
11973 if (accessorElement is! PropertyAccessorElement) { 11973 if (accessorElement is! PropertyAccessorElement) {
11974 return; 11974 return;
11975 } 11975 }
11976 PropertyAccessorElement propertyAccessorElement = accessorElement as Propert yAccessorElement; 11976 PropertyAccessorElement propertyAccessorElement = accessorElement as Propert yAccessorElement;
11977 counterpartAccessor = propertyAccessorElement.correspondingSetter; 11977 counterpartAccessor = propertyAccessorElement.correspondingSetter;
11978 if (counterpartAccessor == null) { 11978 if (counterpartAccessor == null) {
11979 return; 11979 return;
11980 } 11980 }
11981 Type2 getterType = null; 11981 Type2 getterType = null;
11982 Type2 setterType = null; 11982 Type2 setterType = null;
11983 if (propertyAccessorElement.isGetter()) { 11983 if (propertyAccessorElement.isGetter) {
11984 getterType = getGetterType(propertyAccessorElement); 11984 getterType = getGetterType(propertyAccessorElement);
11985 setterType = getSetterType(counterpartAccessor); 11985 setterType = getSetterType(counterpartAccessor);
11986 } else if (propertyAccessorElement.isSetter()) { 11986 } else if (propertyAccessorElement.isSetter) {
11987 setterType = getSetterType(propertyAccessorElement); 11987 setterType = getSetterType(propertyAccessorElement);
11988 counterpartAccessor = propertyAccessorElement.correspondingGetter; 11988 counterpartAccessor = propertyAccessorElement.correspondingGetter;
11989 getterType = getGetterType(counterpartAccessor); 11989 getterType = getGetterType(counterpartAccessor);
11990 } 11990 }
11991 if (setterType != null && getterType != null && !getterType.isAssignableTo(s etterType)) { 11991 if (setterType != null && getterType != null && !getterType.isAssignableTo(s etterType)) {
11992 _errorReporter.reportError2(StaticWarningCode.MISMATCHED_GETTER_AND_SETTER _TYPES, accessorDeclaration, [accessorTextName, setterType.displayName, getterTy pe.displayName]); 11992 _errorReporter.reportError2(StaticWarningCode.MISMATCHED_GETTER_AND_SETTER _TYPES, accessorDeclaration, [accessorTextName, setterType.displayName, getterTy pe.displayName]);
11993 } 11993 }
11994 } 11994 }
11995 11995
11996 /** 11996 /**
11997 * This verifies that the passed mixin does not have an explicitly declared co nstructor. 11997 * This verifies that the passed mixin does not have an explicitly declared co nstructor.
11998 * @param mixinName the node to report problem on 11998 * @param mixinName the node to report problem on
11999 * @param mixinElement the mixing to evaluate 11999 * @param mixinElement the mixing to evaluate
12000 * @return `true` if and only if an error code is generated on the passed node 12000 * @return `true` if and only if an error code is generated on the passed node
12001 * @see CompileTimeErrorCode#MIXIN_DECLARES_CONSTRUCTOR 12001 * @see CompileTimeErrorCode#MIXIN_DECLARES_CONSTRUCTOR
12002 */ 12002 */
12003 bool checkForMixinDeclaresConstructor(TypeName mixinName, ClassElement mixinEl ement) { 12003 bool checkForMixinDeclaresConstructor(TypeName mixinName, ClassElement mixinEl ement) {
12004 for (ConstructorElement constructor in mixinElement.constructors) { 12004 for (ConstructorElement constructor in mixinElement.constructors) {
12005 if (!constructor.isSynthetic() && !constructor.isFactory()) { 12005 if (!constructor.isSynthetic && !constructor.isFactory) {
12006 _errorReporter.reportError2(CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUC TOR, mixinName, [mixinElement.name]); 12006 _errorReporter.reportError2(CompileTimeErrorCode.MIXIN_DECLARES_CONSTRUC TOR, mixinName, [mixinElement.name]);
12007 return true; 12007 return true;
12008 } 12008 }
12009 } 12009 }
12010 return false; 12010 return false;
12011 } 12011 }
12012 12012
12013 /** 12013 /**
12014 * This verifies that the passed mixin has the 'Object' superclass. 12014 * This verifies that the passed mixin has the 'Object' superclass.
12015 * @param mixinName the node to report problem on 12015 * @param mixinName the node to report problem on
12016 * @param mixinElement the mixing to evaluate 12016 * @param mixinElement the mixing to evaluate
12017 * @return `true` if and only if an error code is generated on the passed node 12017 * @return `true` if and only if an error code is generated on the passed node
12018 * @see CompileTimeErrorCode#MIXIN_INHERITS_FROM_NOT_OBJECT 12018 * @see CompileTimeErrorCode#MIXIN_INHERITS_FROM_NOT_OBJECT
12019 */ 12019 */
12020 bool checkForMixinInheritsNotFromObject(TypeName mixinName, ClassElement mixin Element) { 12020 bool checkForMixinInheritsNotFromObject(TypeName mixinName, ClassElement mixin Element) {
12021 InterfaceType mixinSupertype = mixinElement.supertype; 12021 InterfaceType mixinSupertype = mixinElement.supertype;
12022 if (mixinSupertype != null) { 12022 if (mixinSupertype != null) {
12023 if (!mixinSupertype.isObject() || !mixinElement.isTypedef() && mixinElemen t.mixins.length != 0) { 12023 if (!mixinSupertype.isObject || !mixinElement.isTypedef && mixinElement.mi xins.length != 0) {
12024 _errorReporter.reportError2(CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT _OBJECT, mixinName, [mixinElement.name]); 12024 _errorReporter.reportError2(CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT _OBJECT, mixinName, [mixinElement.name]);
12025 return true; 12025 return true;
12026 } 12026 }
12027 } 12027 }
12028 return false; 12028 return false;
12029 } 12029 }
12030 12030
12031 /** 12031 /**
12032 * This verifies that the passed mixin does not reference 'super'. 12032 * This verifies that the passed mixin does not reference 'super'.
12033 * @param mixinName the node to report problem on 12033 * @param mixinName the node to report problem on
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
12107 12107
12108 /** 12108 /**
12109 * This checks that passed if the passed class declaration implicitly calls de fault constructor of 12109 * This checks that passed if the passed class declaration implicitly calls de fault constructor of
12110 * its superclass, there should be such default constructor - implicit or expl icit. 12110 * its superclass, there should be such default constructor - implicit or expl icit.
12111 * @param node the [ClassDeclaration] to evaluate 12111 * @param node the [ClassDeclaration] to evaluate
12112 * @return `true` if and only if an error code is generated on the passed node 12112 * @return `true` if and only if an error code is generated on the passed node
12113 * @see StaticWarningCode#NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT 12113 * @see StaticWarningCode#NO_DEFAULT_SUPER_CONSTRUCTOR_IMPLICIT
12114 */ 12114 */
12115 bool checkForNoDefaultSuperConstructorImplicit(ClassDeclaration node) { 12115 bool checkForNoDefaultSuperConstructorImplicit(ClassDeclaration node) {
12116 List<ConstructorElement> constructors = _enclosingClass.constructors; 12116 List<ConstructorElement> constructors = _enclosingClass.constructors;
12117 if (!constructors[0].isSynthetic()) { 12117 if (!constructors[0].isSynthetic) {
12118 return false; 12118 return false;
12119 } 12119 }
12120 InterfaceType superType = _enclosingClass.supertype; 12120 InterfaceType superType = _enclosingClass.supertype;
12121 if (superType == null) { 12121 if (superType == null) {
12122 return false; 12122 return false;
12123 } 12123 }
12124 ClassElement superClass = superType.element; 12124 ClassElement superClass = superType.element;
12125 if (superClass.hasDefaultConstructor()) { 12125 if (superClass.hasDefaultConstructor()) {
12126 return false; 12126 return false;
12127 } 12127 }
12128 _errorReporter.reportError2(StaticWarningCode.NO_DEFAULT_SUPER_CONSTRUCTOR_I MPLICIT, node.name, [superType.displayName]); 12128 _errorReporter.reportError2(StaticWarningCode.NO_DEFAULT_SUPER_CONSTRUCTOR_I MPLICIT, node.name, [superType.displayName]);
12129 return true; 12129 return true;
12130 } 12130 }
12131 12131
12132 /** 12132 /**
12133 * This checks that passed class declaration overrides all members required by its superclasses 12133 * This checks that passed class declaration overrides all members required by its superclasses
12134 * and interfaces. 12134 * and interfaces.
12135 * @param node the [ClassDeclaration] to evaluate 12135 * @param node the [ClassDeclaration] to evaluate
12136 * @return `true` if and only if an error code is generated on the passed node 12136 * @return `true` if and only if an error code is generated on the passed node
12137 * @see StaticWarningCode#NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE 12137 * @see StaticWarningCode#NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE
12138 * @see StaticWarningCode#NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_TWO 12138 * @see StaticWarningCode#NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_TWO
12139 * @see StaticWarningCode#NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_THREE 12139 * @see StaticWarningCode#NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_THREE
12140 * @see StaticWarningCode#NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FOUR 12140 * @see StaticWarningCode#NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FOUR
12141 * @see StaticWarningCode#NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FIVE_PLU S 12141 * @see StaticWarningCode#NON_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_FIVE_PLU S
12142 */ 12142 */
12143 bool checkForNonAbstractClassInheritsAbstractMember(ClassDeclaration node) { 12143 bool checkForNonAbstractClassInheritsAbstractMember(ClassDeclaration node) {
12144 if (_enclosingClass.isAbstract()) { 12144 if (_enclosingClass.isAbstract) {
12145 return false; 12145 return false;
12146 } 12146 }
12147 Set<ExecutableElement> missingOverrides = new Set<ExecutableElement>(); 12147 Set<ExecutableElement> missingOverrides = new Set<ExecutableElement>();
12148 Set<String> methodsInEnclosingClass = new Set<String>(); 12148 Set<String> methodsInEnclosingClass = new Set<String>();
12149 Set<String> accessorsInEnclosingClass = new Set<String>(); 12149 Set<String> accessorsInEnclosingClass = new Set<String>();
12150 List<MethodElement> methods = _enclosingClass.methods; 12150 List<MethodElement> methods = _enclosingClass.methods;
12151 for (MethodElement method in methods) { 12151 for (MethodElement method in methods) {
12152 javaSetAdd(methodsInEnclosingClass, method.name); 12152 javaSetAdd(methodsInEnclosingClass, method.name);
12153 } 12153 }
12154 List<PropertyAccessorElement> accessors = _enclosingClass.accessors; 12154 List<PropertyAccessorElement> accessors = _enclosingClass.accessors;
12155 for (PropertyAccessorElement accessor in accessors) { 12155 for (PropertyAccessorElement accessor in accessors) {
12156 javaSetAdd(accessorsInEnclosingClass, accessor.name); 12156 javaSetAdd(accessorsInEnclosingClass, accessor.name);
12157 } 12157 }
12158 Map<String, ExecutableElement> membersInheritedFromSuperclasses = _inheritan ceManager.getMapOfMembersInheritedFromClasses(_enclosingClass); 12158 Map<String, ExecutableElement> membersInheritedFromSuperclasses = _inheritan ceManager.getMapOfMembersInheritedFromClasses(_enclosingClass);
12159 for (MapEntry<String, ExecutableElement> entry in getMapEntrySet(membersInhe ritedFromSuperclasses)) { 12159 for (MapEntry<String, ExecutableElement> entry in getMapEntrySet(membersInhe ritedFromSuperclasses)) {
12160 ExecutableElement executableElt = entry.getValue(); 12160 ExecutableElement executableElt = entry.getValue();
12161 if (executableElt is MethodElement) { 12161 if (executableElt is MethodElement) {
12162 MethodElement methodElt = executableElt as MethodElement; 12162 MethodElement methodElt = executableElt as MethodElement;
12163 if (methodElt.isAbstract()) { 12163 if (methodElt.isAbstract) {
12164 String methodName = entry.getKey(); 12164 String methodName = entry.getKey();
12165 if (!methodsInEnclosingClass.contains(methodName)) { 12165 if (!methodsInEnclosingClass.contains(methodName)) {
12166 javaSetAdd(missingOverrides, executableElt); 12166 javaSetAdd(missingOverrides, executableElt);
12167 } 12167 }
12168 } 12168 }
12169 } else if (executableElt is PropertyAccessorElement) { 12169 } else if (executableElt is PropertyAccessorElement) {
12170 PropertyAccessorElement propertyAccessorElt = executableElt as PropertyA ccessorElement; 12170 PropertyAccessorElement propertyAccessorElt = executableElt as PropertyA ccessorElement;
12171 if (propertyAccessorElt.isAbstract()) { 12171 if (propertyAccessorElt.isAbstract) {
12172 String accessorName = entry.getKey(); 12172 String accessorName = entry.getKey();
12173 if (!accessorsInEnclosingClass.contains(accessorName)) { 12173 if (!accessorsInEnclosingClass.contains(accessorName)) {
12174 javaSetAdd(missingOverrides, executableElt); 12174 javaSetAdd(missingOverrides, executableElt);
12175 } 12175 }
12176 } 12176 }
12177 } 12177 }
12178 } 12178 }
12179 Map<String, ExecutableElement> membersInheritedFromInterfaces = _inheritance Manager.getMapOfMembersInheritedFromInterfaces(_enclosingClass); 12179 Map<String, ExecutableElement> membersInheritedFromInterfaces = _inheritance Manager.getMapOfMembersInheritedFromInterfaces(_enclosingClass);
12180 for (MapEntry<String, ExecutableElement> entry in getMapEntrySet(membersInhe ritedFromInterfaces)) { 12180 for (MapEntry<String, ExecutableElement> entry in getMapEntrySet(membersInhe ritedFromInterfaces)) {
12181 ExecutableElement executableElt = entry.getValue(); 12181 ExecutableElement executableElt = entry.getValue();
12182 ExecutableElement elt = membersInheritedFromSuperclasses[executableElt.nam e]; 12182 ExecutableElement elt = membersInheritedFromSuperclasses[executableElt.nam e];
12183 if (elt != null) { 12183 if (elt != null) {
12184 if (elt is MethodElement && !((elt as MethodElement)).isAbstract()) { 12184 if (elt is MethodElement && !((elt as MethodElement)).isAbstract) {
12185 continue; 12185 continue;
12186 } else if (elt is PropertyAccessorElement && !((elt as PropertyAccessorE lement)).isAbstract()) { 12186 } else if (elt is PropertyAccessorElement && !((elt as PropertyAccessorE lement)).isAbstract) {
12187 continue; 12187 continue;
12188 } 12188 }
12189 } 12189 }
12190 if (executableElt is MethodElement) { 12190 if (executableElt is MethodElement) {
12191 String methodName = entry.getKey(); 12191 String methodName = entry.getKey();
12192 if (!methodsInEnclosingClass.contains(methodName)) { 12192 if (!methodsInEnclosingClass.contains(methodName)) {
12193 javaSetAdd(missingOverrides, executableElt); 12193 javaSetAdd(missingOverrides, executableElt);
12194 } 12194 }
12195 } else if (executableElt is PropertyAccessorElement) { 12195 } else if (executableElt is PropertyAccessorElement) {
12196 String accessorName = entry.getKey(); 12196 String accessorName = entry.getKey();
12197 if (!accessorsInEnclosingClass.contains(accessorName)) { 12197 if (!accessorsInEnclosingClass.contains(accessorName)) {
12198 javaSetAdd(missingOverrides, executableElt); 12198 javaSetAdd(missingOverrides, executableElt);
12199 } 12199 }
12200 } 12200 }
12201 } 12201 }
12202 int missingOverridesSize = missingOverrides.length; 12202 int missingOverridesSize = missingOverrides.length;
12203 if (missingOverridesSize == 0) { 12203 if (missingOverridesSize == 0) {
12204 return false; 12204 return false;
12205 } 12205 }
12206 List<ExecutableElement> missingOverridesArray = new List.from(missingOverrid es); 12206 List<ExecutableElement> missingOverridesArray = new List.from(missingOverrid es);
12207 List<String> stringTypeArray = new List<String>(Math.min(missingOverridesSiz e, 4)); 12207 List<String> stringTypeArray = new List<String>(Math.min(missingOverridesSiz e, 4));
12208 String GET = "get "; 12208 String GET = "get ";
12209 String SET = "set "; 12209 String SET = "set ";
12210 for (int i = 0; i < stringTypeArray.length; i++) { 12210 for (int i = 0; i < stringTypeArray.length; i++) {
12211 stringTypeArray[i] = StringUtilities.EMPTY; 12211 stringTypeArray[i] = StringUtilities.EMPTY;
12212 if (missingOverridesArray[i] is PropertyAccessorElement) { 12212 if (missingOverridesArray[i] is PropertyAccessorElement) {
12213 stringTypeArray[i] = ((missingOverridesArray[i] as PropertyAccessorEleme nt)).isGetter() ? GET : SET; 12213 stringTypeArray[i] = ((missingOverridesArray[i] as PropertyAccessorEleme nt)).isGetter ? GET : SET;
12214 } 12214 }
12215 } 12215 }
12216 AnalysisErrorWithProperties analysisError; 12216 AnalysisErrorWithProperties analysisError;
12217 if (missingOverridesSize == 1) { 12217 if (missingOverridesSize == 1) {
12218 analysisError = _errorReporter.newErrorWithProperties(StaticWarningCode.NO N_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE, node.name, [stringTypeArray[0], m issingOverridesArray[0].enclosingElement.displayName, missingOverridesArray[0].d isplayName]); 12218 analysisError = _errorReporter.newErrorWithProperties(StaticWarningCode.NO N_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_ONE, node.name, [stringTypeArray[0], m issingOverridesArray[0].enclosingElement.displayName, missingOverridesArray[0].d isplayName]);
12219 } else if (missingOverridesSize == 2) { 12219 } else if (missingOverridesSize == 2) {
12220 analysisError = _errorReporter.newErrorWithProperties(StaticWarningCode.NO N_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_TWO, node.name, [stringTypeArray[0], m issingOverridesArray[0].enclosingElement.displayName, missingOverridesArray[0].d isplayName, stringTypeArray[1], missingOverridesArray[1].enclosingElement.displa yName, missingOverridesArray[1].displayName]); 12220 analysisError = _errorReporter.newErrorWithProperties(StaticWarningCode.NO N_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_TWO, node.name, [stringTypeArray[0], m issingOverridesArray[0].enclosingElement.displayName, missingOverridesArray[0].d isplayName, stringTypeArray[1], missingOverridesArray[1].enclosingElement.displa yName, missingOverridesArray[1].displayName]);
12221 } else if (missingOverridesSize == 3) { 12221 } else if (missingOverridesSize == 3) {
12222 analysisError = _errorReporter.newErrorWithProperties(StaticWarningCode.NO N_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_THREE, node.name, [stringTypeArray[0], missingOverridesArray[0].enclosingElement.displayName, missingOverridesArray[0] .displayName, stringTypeArray[1], missingOverridesArray[1].enclosingElement.disp layName, missingOverridesArray[1].displayName, stringTypeArray[2], missingOverri desArray[2].enclosingElement.displayName, missingOverridesArray[2].displayName]) ; 12222 analysisError = _errorReporter.newErrorWithProperties(StaticWarningCode.NO N_ABSTRACT_CLASS_INHERITS_ABSTRACT_MEMBER_THREE, node.name, [stringTypeArray[0], missingOverridesArray[0].enclosingElement.displayName, missingOverridesArray[0] .displayName, stringTypeArray[1], missingOverridesArray[1].enclosingElement.disp layName, missingOverridesArray[1].displayName, stringTypeArray[2], missingOverri desArray[2].enclosingElement.displayName, missingOverridesArray[2].displayName]) ;
12223 } else if (missingOverridesSize == 4) { 12223 } else if (missingOverridesSize == 4) {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
12307 * @see StaticWarningCode#NON_VOID_RETURN_FOR_OPERATOR 12307 * @see StaticWarningCode#NON_VOID_RETURN_FOR_OPERATOR
12308 */ 12308 */
12309 bool checkForNonVoidReturnTypeForOperator(MethodDeclaration node) { 12309 bool checkForNonVoidReturnTypeForOperator(MethodDeclaration node) {
12310 SimpleIdentifier name = node.name; 12310 SimpleIdentifier name = node.name;
12311 if (name.name != "[]=") { 12311 if (name.name != "[]=") {
12312 return false; 12312 return false;
12313 } 12313 }
12314 TypeName typeName = node.returnType; 12314 TypeName typeName = node.returnType;
12315 if (typeName != null) { 12315 if (typeName != null) {
12316 Type2 type = typeName.type; 12316 Type2 type = typeName.type;
12317 if (type != null && !type.isVoid()) { 12317 if (type != null && !type.isVoid) {
12318 _errorReporter.reportError2(StaticWarningCode.NON_VOID_RETURN_FOR_OPERAT OR, typeName, []); 12318 _errorReporter.reportError2(StaticWarningCode.NON_VOID_RETURN_FOR_OPERAT OR, typeName, []);
12319 } 12319 }
12320 } 12320 }
12321 return false; 12321 return false;
12322 } 12322 }
12323 12323
12324 /** 12324 /**
12325 * This verifies the passed setter has no return type or the `void` return typ e. 12325 * This verifies the passed setter has no return type or the `void` return typ e.
12326 * @param typeName the type name to evaluate 12326 * @param typeName the type name to evaluate
12327 * @return `true` if and only if an error code is generated on the passed node 12327 * @return `true` if and only if an error code is generated on the passed node
12328 * @see StaticWarningCode#NON_VOID_RETURN_FOR_SETTER 12328 * @see StaticWarningCode#NON_VOID_RETURN_FOR_SETTER
12329 */ 12329 */
12330 bool checkForNonVoidReturnTypeForSetter(TypeName typeName) { 12330 bool checkForNonVoidReturnTypeForSetter(TypeName typeName) {
12331 if (typeName != null) { 12331 if (typeName != null) {
12332 Type2 type = typeName.type; 12332 Type2 type = typeName.type;
12333 if (type != null && !type.isVoid()) { 12333 if (type != null && !type.isVoid) {
12334 _errorReporter.reportError2(StaticWarningCode.NON_VOID_RETURN_FOR_SETTER , typeName, []); 12334 _errorReporter.reportError2(StaticWarningCode.NON_VOID_RETURN_FOR_SETTER , typeName, []);
12335 } 12335 }
12336 } 12336 }
12337 return false; 12337 return false;
12338 } 12338 }
12339 12339
12340 /** 12340 /**
12341 * This verifies the passed operator-method declaration, does not have an opti onal parameter. 12341 * This verifies the passed operator-method declaration, does not have an opti onal parameter.
12342 * 12342 *
12343 * This method assumes that the method declaration was tested to be an operato r declaration before 12343 * This method assumes that the method declaration was tested to be an operato r declaration before
12344 * being called. 12344 * being called.
12345 * @param node the method declaration to evaluate 12345 * @param node the method declaration to evaluate
12346 * @return `true` if and only if an error code is generated on the passed node 12346 * @return `true` if and only if an error code is generated on the passed node
12347 * @see CompileTimeErrorCode#OPTIONAL_PARAMETER_IN_OPERATOR 12347 * @see CompileTimeErrorCode#OPTIONAL_PARAMETER_IN_OPERATOR
12348 */ 12348 */
12349 bool checkForOptionalParameterInOperator(MethodDeclaration node) { 12349 bool checkForOptionalParameterInOperator(MethodDeclaration node) {
12350 FormalParameterList parameterList = node.parameters; 12350 FormalParameterList parameterList = node.parameters;
12351 if (parameterList == null) { 12351 if (parameterList == null) {
12352 return false; 12352 return false;
12353 } 12353 }
12354 bool foundError = false; 12354 bool foundError = false;
12355 NodeList<FormalParameter> formalParameters = parameterList.parameters; 12355 NodeList<FormalParameter> formalParameters = parameterList.parameters;
12356 for (FormalParameter formalParameter in formalParameters) { 12356 for (FormalParameter formalParameter in formalParameters) {
12357 if (formalParameter.kind.isOptional()) { 12357 if (formalParameter.kind.isOptional) {
12358 _errorReporter.reportError2(CompileTimeErrorCode.OPTIONAL_PARAMETER_IN_O PERATOR, formalParameter, []); 12358 _errorReporter.reportError2(CompileTimeErrorCode.OPTIONAL_PARAMETER_IN_O PERATOR, formalParameter, []);
12359 foundError = true; 12359 foundError = true;
12360 } 12360 }
12361 } 12361 }
12362 return foundError; 12362 return foundError;
12363 } 12363 }
12364 12364
12365 /** 12365 /**
12366 * This checks for named optional parameters that begin with '_'. 12366 * This checks for named optional parameters that begin with '_'.
12367 * @param node the default formal parameter to evaluate 12367 * @param node the default formal parameter to evaluate
12368 * @return `true` if and only if an error code is generated on the passed node 12368 * @return `true` if and only if an error code is generated on the passed node
12369 * @see CompileTimeErrorCode#PRIVATE_OPTIONAL_PARAMETER 12369 * @see CompileTimeErrorCode#PRIVATE_OPTIONAL_PARAMETER
12370 */ 12370 */
12371 bool checkForPrivateOptionalParameter(DefaultFormalParameter node) { 12371 bool checkForPrivateOptionalParameter(DefaultFormalParameter node) {
12372 sc.Token separator = node.separator; 12372 sc.Token separator = node.separator;
12373 if (separator != null && separator.lexeme == ":") { 12373 if (separator != null && separator.lexeme == ":") {
12374 NormalFormalParameter parameter = node.parameter; 12374 NormalFormalParameter parameter = node.parameter;
12375 SimpleIdentifier name = parameter.identifier; 12375 SimpleIdentifier name = parameter.identifier;
12376 if (!name.isSynthetic() && name.name.startsWith("_")) { 12376 if (!name.isSynthetic && name.name.startsWith("_")) {
12377 _errorReporter.reportError2(CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAME TER, node, []); 12377 _errorReporter.reportError2(CompileTimeErrorCode.PRIVATE_OPTIONAL_PARAME TER, node, []);
12378 return true; 12378 return true;
12379 } 12379 }
12380 } 12380 }
12381 return false; 12381 return false;
12382 } 12382 }
12383 12383
12384 /** 12384 /**
12385 * This checks if the passed constructor declaration is the redirecting genera tive constructor and 12385 * This checks if the passed constructor declaration is the redirecting genera tive constructor and
12386 * references itself directly or indirectly. 12386 * references itself directly or indirectly.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
12461 } 12461 }
12462 } 12462 }
12463 for (int i = 1; i < list.length - 1; i++) { 12463 for (int i = 1; i < list.length - 1; i++) {
12464 if (classElt == list[i]) { 12464 if (classElt == list[i]) {
12465 list.removeAt(list.length - 1); 12465 list.removeAt(list.length - 1);
12466 return false; 12466 return false;
12467 } 12467 }
12468 } 12468 }
12469 List<ClassElement> interfaceElements; 12469 List<ClassElement> interfaceElements;
12470 List<InterfaceType> interfaceTypes = classElt.interfaces; 12470 List<InterfaceType> interfaceTypes = classElt.interfaces;
12471 if (supertype != null && !supertype.isObject()) { 12471 if (supertype != null && !supertype.isObject) {
12472 interfaceElements = new List<ClassElement>(interfaceTypes.length + 1); 12472 interfaceElements = new List<ClassElement>(interfaceTypes.length + 1);
12473 interfaceElements[0] = supertype.element; 12473 interfaceElements[0] = supertype.element;
12474 for (int i = 0; i < interfaceTypes.length; i++) { 12474 for (int i = 0; i < interfaceTypes.length; i++) {
12475 interfaceElements[i + 1] = interfaceTypes[i].element; 12475 interfaceElements[i + 1] = interfaceTypes[i].element;
12476 } 12476 }
12477 } else { 12477 } else {
12478 interfaceElements = new List<ClassElement>(interfaceTypes.length); 12478 interfaceElements = new List<ClassElement>(interfaceTypes.length);
12479 for (int i = 0; i < interfaceTypes.length; i++) { 12479 for (int i = 0; i < interfaceTypes.length; i++) {
12480 interfaceElements[i] = interfaceTypes[i].element; 12480 interfaceElements[i] = interfaceTypes[i].element;
12481 } 12481 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
12534 */ 12534 */
12535 bool checkForRedirectToNonConstConstructor(ConstructorDeclaration node) { 12535 bool checkForRedirectToNonConstConstructor(ConstructorDeclaration node) {
12536 ConstructorName redirectedConstructorNode = node.redirectedConstructor; 12536 ConstructorName redirectedConstructorNode = node.redirectedConstructor;
12537 if (redirectedConstructorNode == null) { 12537 if (redirectedConstructorNode == null) {
12538 return false; 12538 return false;
12539 } 12539 }
12540 ConstructorElement element = node.element; 12540 ConstructorElement element = node.element;
12541 if (element == null) { 12541 if (element == null) {
12542 return false; 12542 return false;
12543 } 12543 }
12544 if (!element.isConst()) { 12544 if (!element.isConst) {
12545 return false; 12545 return false;
12546 } 12546 }
12547 ConstructorElement redirectedConstructor = element.redirectedConstructor; 12547 ConstructorElement redirectedConstructor = element.redirectedConstructor;
12548 if (redirectedConstructor == null) { 12548 if (redirectedConstructor == null) {
12549 return false; 12549 return false;
12550 } 12550 }
12551 if (redirectedConstructor.isConst()) { 12551 if (redirectedConstructor.isConst) {
12552 return false; 12552 return false;
12553 } 12553 }
12554 _errorReporter.reportError2(CompileTimeErrorCode.REDIRECT_TO_NON_CONST_CONST RUCTOR, redirectedConstructorNode, []); 12554 _errorReporter.reportError2(CompileTimeErrorCode.REDIRECT_TO_NON_CONST_CONST RUCTOR, redirectedConstructorNode, []);
12555 return true; 12555 return true;
12556 } 12556 }
12557 12557
12558 /** 12558 /**
12559 * This checks if the passed identifier is banned because it is part of the va riable declaration 12559 * This checks if the passed identifier is banned because it is part of the va riable declaration
12560 * with the same name. 12560 * with the same name.
12561 * @param node the identifier to evaluate 12561 * @param node the identifier to evaluate
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
12621 * enclosing method or function. 12621 * enclosing method or function.
12622 * 12622 *
12623 * This method is called both by [checkForAllReturnStatementErrorCodes]and [vi sitExpressionFunctionBody]. 12623 * This method is called both by [checkForAllReturnStatementErrorCodes]and [vi sitExpressionFunctionBody].
12624 * @param returnExpression the returned expression to evaluate 12624 * @param returnExpression the returned expression to evaluate
12625 * @param expectedReturnType the expressed return type by the enclosing method or function 12625 * @param expectedReturnType the expressed return type by the enclosing method or function
12626 * @return `true` if and only if an error code is generated on the passed node 12626 * @return `true` if and only if an error code is generated on the passed node
12627 * @see StaticTypeWarningCode#RETURN_OF_INVALID_TYPE 12627 * @see StaticTypeWarningCode#RETURN_OF_INVALID_TYPE
12628 */ 12628 */
12629 bool checkForReturnOfInvalidType(Expression returnExpression, Type2 expectedRe turnType) { 12629 bool checkForReturnOfInvalidType(Expression returnExpression, Type2 expectedRe turnType) {
12630 Type2 staticReturnType = getStaticType(returnExpression); 12630 Type2 staticReturnType = getStaticType(returnExpression);
12631 if (expectedReturnType.isVoid()) { 12631 if (expectedReturnType.isVoid) {
12632 if (staticReturnType.isVoid() || staticReturnType.isDynamic() || identical (staticReturnType, BottomTypeImpl.instance)) { 12632 if (staticReturnType.isVoid || staticReturnType.isDynamic || identical(sta ticReturnType, BottomTypeImpl.instance)) {
12633 return false; 12633 return false;
12634 } 12634 }
12635 _errorReporter.reportError2(StaticTypeWarningCode.RETURN_OF_INVALID_TYPE, returnExpression, [staticReturnType.displayName, expectedReturnType.displayName, _enclosingFunction.displayName]); 12635 _errorReporter.reportError2(StaticTypeWarningCode.RETURN_OF_INVALID_TYPE, returnExpression, [staticReturnType.displayName, expectedReturnType.displayName, _enclosingFunction.displayName]);
12636 return true; 12636 return true;
12637 } 12637 }
12638 bool isStaticAssignable = staticReturnType.isAssignableTo(expectedReturnType ); 12638 bool isStaticAssignable = staticReturnType.isAssignableTo(expectedReturnType );
12639 Type2 propagatedReturnType = getPropagatedType(returnExpression); 12639 Type2 propagatedReturnType = getPropagatedType(returnExpression);
12640 if (_strictMode || propagatedReturnType == null) { 12640 if (_strictMode || propagatedReturnType == null) {
12641 if (isStaticAssignable) { 12641 if (isStaticAssignable) {
12642 return false; 12642 return false;
(...skipping 17 matching lines...) Expand all
12660 * @param name the accessed name to evaluate 12660 * @param name the accessed name to evaluate
12661 * @return `true` if and only if an error code is generated on the passed node 12661 * @return `true` if and only if an error code is generated on the passed node
12662 * @see StaticWarningCode#STATIC_ACCESS_TO_INSTANCE_MEMBER 12662 * @see StaticWarningCode#STATIC_ACCESS_TO_INSTANCE_MEMBER
12663 */ 12663 */
12664 bool checkForStaticAccessToInstanceMember(Expression target, SimpleIdentifier name2) { 12664 bool checkForStaticAccessToInstanceMember(Expression target, SimpleIdentifier name2) {
12665 Element element = name2.element; 12665 Element element = name2.element;
12666 if (element is! ExecutableElement) { 12666 if (element is! ExecutableElement) {
12667 return false; 12667 return false;
12668 } 12668 }
12669 ExecutableElement memberElement = element as ExecutableElement; 12669 ExecutableElement memberElement = element as ExecutableElement;
12670 if (memberElement.isStatic()) { 12670 if (memberElement.isStatic) {
12671 return false; 12671 return false;
12672 } 12672 }
12673 if (!isTypeReference(target)) { 12673 if (!isTypeReference(target)) {
12674 return false; 12674 return false;
12675 } 12675 }
12676 _errorReporter.reportError2(StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMB ER, name2, [name2.name]); 12676 _errorReporter.reportError2(StaticWarningCode.STATIC_ACCESS_TO_INSTANCE_MEMB ER, name2, [name2.name]);
12677 return true; 12677 return true;
12678 } 12678 }
12679 12679
12680 /** 12680 /**
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
12759 if (_enclosingClass == null) { 12759 if (_enclosingClass == null) {
12760 return false; 12760 return false;
12761 } 12761 }
12762 InterfaceType superType = _enclosingClass.supertype; 12762 InterfaceType superType = _enclosingClass.supertype;
12763 if (superType == null) { 12763 if (superType == null) {
12764 return false; 12764 return false;
12765 } 12765 }
12766 ClassElement superElement = superType.element; 12766 ClassElement superElement = superType.element;
12767 ConstructorElement superUnnamedConstructor = superElement.unnamedConstructor ; 12767 ConstructorElement superUnnamedConstructor = superElement.unnamedConstructor ;
12768 if (superUnnamedConstructor != null) { 12768 if (superUnnamedConstructor != null) {
12769 if (superUnnamedConstructor.isFactory()) { 12769 if (superUnnamedConstructor.isFactory) {
12770 _errorReporter.reportError2(CompileTimeErrorCode.NON_GENERATIVE_CONSTRUC TOR, node.returnType, [superUnnamedConstructor]); 12770 _errorReporter.reportError2(CompileTimeErrorCode.NON_GENERATIVE_CONSTRUC TOR, node.returnType, [superUnnamedConstructor]);
12771 return true; 12771 return true;
12772 } 12772 }
12773 if (!superUnnamedConstructor.isDefaultConstructor()) { 12773 if (!superUnnamedConstructor.isDefaultConstructor) {
12774 int offset; 12774 int offset;
12775 int length; 12775 int length;
12776 { 12776 {
12777 Identifier returnType = node.returnType; 12777 Identifier returnType = node.returnType;
12778 SimpleIdentifier name = node.name; 12778 SimpleIdentifier name = node.name;
12779 offset = returnType.offset; 12779 offset = returnType.offset;
12780 length = (name != null ? name.end : returnType.end) - offset; 12780 length = (name != null ? name.end : returnType.end) - offset;
12781 } 12781 }
12782 _errorReporter.reportError3(StaticWarningCode.NO_DEFAULT_SUPER_CONSTRUCT OR_EXPLICIT, offset, length, [superType.displayName]); 12782 _errorReporter.reportError3(StaticWarningCode.NO_DEFAULT_SUPER_CONSTRUCT OR_EXPLICIT, offset, length, [superType.displayName]);
12783 } 12783 }
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
12957 } 12957 }
12958 if (n is ConstructorDeclaration) { 12958 if (n is ConstructorDeclaration) {
12959 ConstructorDeclaration constructor = n as ConstructorDeclaration; 12959 ConstructorDeclaration constructor = n as ConstructorDeclaration;
12960 return constructor.factoryKeyword == null; 12960 return constructor.factoryKeyword == null;
12961 } 12961 }
12962 if (n is ConstructorFieldInitializer) { 12962 if (n is ConstructorFieldInitializer) {
12963 return false; 12963 return false;
12964 } 12964 }
12965 if (n is MethodDeclaration) { 12965 if (n is MethodDeclaration) {
12966 MethodDeclaration method = n as MethodDeclaration; 12966 MethodDeclaration method = n as MethodDeclaration;
12967 return !method.isStatic(); 12967 return !method.isStatic;
12968 } 12968 }
12969 } 12969 }
12970 return false; 12970 return false;
12971 } 12971 }
12972 } 12972 }
12973 /** 12973 /**
12974 * This enum holds one of four states of a field initialization state through a constructor 12974 * This enum holds one of four states of a field initialization state through a constructor
12975 * signature, not initialized, initialized in the field declaration, initialized in the field 12975 * signature, not initialized, initialized in the field declaration, initialized in the field
12976 * formal, and finally, initialized in the initializers list. 12976 * formal, and finally, initialized in the initializers list.
12977 */ 12977 */
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
13178 this._type = type; 13178 this._type = type;
13179 this._message = message; 13179 this._message = message;
13180 } 13180 }
13181 ErrorSeverity get errorSeverity => _type.severity; 13181 ErrorSeverity get errorSeverity => _type.severity;
13182 String get message => _message; 13182 String get message => _message;
13183 ErrorType get type => _type; 13183 ErrorType get type => _type;
13184 int compareTo(ResolverErrorCode other) => ordinal - other.ordinal; 13184 int compareTo(ResolverErrorCode other) => ordinal - other.ordinal;
13185 int get hashCode => ordinal; 13185 int get hashCode => ordinal;
13186 String toString() => name; 13186 String toString() => name;
13187 } 13187 }
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