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

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

Issue 243263004: New analyzer snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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
« no previous file with comments | « pkg/analyzer/lib/src/generated/parser.dart ('k') | pkg/analyzer/lib/src/generated/sdk_io.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.resolver; 8 library engine.resolver;
9 9
10 import 'dart:collection'; 10 import 'dart:collection';
11 import 'java_core.dart'; 11 import 'java_core.dart';
12 import 'java_engine.dart'; 12 import 'java_engine.dart';
13 import 'instrumentation.dart'; 13 import 'instrumentation.dart';
14 import 'source.dart'; 14 import 'source.dart';
15 import 'error.dart'; 15 import 'error.dart';
16 import 'scanner.dart' as sc; 16 import 'scanner.dart' as sc;
17 import 'utilities_dart.dart'; 17 import 'utilities_dart.dart';
18 import 'utilities_general.dart'; 18 import 'utilities_general.dart';
19 import 'utilities_collection.dart';
20 import 'ast.dart'; 19 import 'ast.dart';
21 import 'parser.dart' show Parser, ParserErrorCode; 20 import 'parser.dart' show Parser, ParserErrorCode;
22 import 'sdk.dart' show DartSdk, SdkLibrary; 21 import 'sdk.dart' show DartSdk, SdkLibrary;
23 import 'element.dart'; 22 import 'element.dart';
24 import 'html.dart' as ht; 23 import 'html.dart' as ht;
25 import 'engine.dart'; 24 import 'engine.dart';
26 import 'constant.dart'; 25 import 'constant.dart';
27 26
28 /** 27 /**
29 * Instances of the class `AngularCompilationUnitBuilder` build an Angular speci fic element 28 * Instances of the class `AngularCompilationUnitBuilder` build an Angular speci fic element
(...skipping 5634 matching lines...) Expand 10 before | Expand all | Expand 10 after
5664 Expression leftHandSide = node.leftHandSide; 5663 Expression leftHandSide = node.leftHandSide;
5665 if (leftHandSide != null) { 5664 if (leftHandSide != null) {
5666 String methodName = operatorType.lexeme; 5665 String methodName = operatorType.lexeme;
5667 DartType staticType = _getStaticType(leftHandSide); 5666 DartType staticType = _getStaticType(leftHandSide);
5668 MethodElement staticMethod = _lookUpMethod(leftHandSide, staticType, met hodName); 5667 MethodElement staticMethod = _lookUpMethod(leftHandSide, staticType, met hodName);
5669 node.staticElement = staticMethod; 5668 node.staticElement = staticMethod;
5670 DartType propagatedType = _getPropagatedType(leftHandSide); 5669 DartType propagatedType = _getPropagatedType(leftHandSide);
5671 MethodElement propagatedMethod = _lookUpMethod(leftHandSide, propagatedT ype, methodName); 5670 MethodElement propagatedMethod = _lookUpMethod(leftHandSide, propagatedT ype, methodName);
5672 node.propagatedElement = propagatedMethod; 5671 node.propagatedElement = propagatedMethod;
5673 if (_shouldReportMissingMember(staticType, staticMethod)) { 5672 if (_shouldReportMissingMember(staticType, staticMethod)) {
5674 _resolver.reportProxyConditionalErrorForToken(staticType.element, Stat icTypeWarningCode.UNDEFINED_METHOD, operator, [methodName, staticType.displayNam e]); 5673 if (_doesClassElementHaveProxy(staticType.element)) {
5674 _resolver.reportErrorForToken(StaticTypeWarningCode.UNDEFINED_METHOD , operator, [methodName, staticType.displayName]);
5675 }
5675 } else if (_enableHints && _shouldReportMissingMember(propagatedType, pr opagatedMethod) && !_memberFoundInSubclass(propagatedType.element, methodName, t rue, false)) { 5676 } else if (_enableHints && _shouldReportMissingMember(propagatedType, pr opagatedMethod) && !_memberFoundInSubclass(propagatedType.element, methodName, t rue, false)) {
5676 _resolver.reportProxyConditionalErrorForToken(propagatedType.element, HintCode.UNDEFINED_METHOD, operator, [methodName, propagatedType.displayName]); 5677 if (_doesClassElementHaveProxy(propagatedType.element)) {
5678 _resolver.reportErrorForToken(HintCode.UNDEFINED_METHOD, operator, [ methodName, propagatedType.displayName]);
5679 }
5677 } 5680 }
5678 } 5681 }
5679 } 5682 }
5680 return null; 5683 return null;
5681 } 5684 }
5682 5685
5683 @override 5686 @override
5684 Object visitBinaryExpression(BinaryExpression node) { 5687 Object visitBinaryExpression(BinaryExpression node) {
5685 sc.Token operator = node.operator; 5688 sc.Token operator = node.operator;
5686 if (operator.isUserDefinableOperator) { 5689 if (operator.isUserDefinableOperator) {
5687 Expression leftOperand = node.leftOperand; 5690 Expression leftOperand = node.leftOperand;
5688 if (leftOperand != null) { 5691 if (leftOperand != null) {
5689 String methodName = operator.lexeme; 5692 String methodName = operator.lexeme;
5690 DartType staticType = _getStaticType(leftOperand); 5693 DartType staticType = _getStaticType(leftOperand);
5691 MethodElement staticMethod = _lookUpMethod(leftOperand, staticType, meth odName); 5694 MethodElement staticMethod = _lookUpMethod(leftOperand, staticType, meth odName);
5692 node.staticElement = staticMethod; 5695 node.staticElement = staticMethod;
5693 DartType propagatedType = _getPropagatedType(leftOperand); 5696 DartType propagatedType = _getPropagatedType(leftOperand);
5694 MethodElement propagatedMethod = _lookUpMethod(leftOperand, propagatedTy pe, methodName); 5697 MethodElement propagatedMethod = _lookUpMethod(leftOperand, propagatedTy pe, methodName);
5695 node.propagatedElement = propagatedMethod; 5698 node.propagatedElement = propagatedMethod;
5696 if (_shouldReportMissingMember(staticType, staticMethod)) { 5699 if (_shouldReportMissingMember(staticType, staticMethod)) {
5697 _resolver.reportProxyConditionalErrorForToken(staticType.element, Stat icTypeWarningCode.UNDEFINED_OPERATOR, operator, [methodName, staticType.displayN ame]); 5700 if (_doesClassElementHaveProxy(staticType.element)) {
5701 _resolver.reportErrorForToken(StaticTypeWarningCode.UNDEFINED_OPERAT OR, operator, [methodName, staticType.displayName]);
5702 }
5698 } else if (_enableHints && _shouldReportMissingMember(propagatedType, pr opagatedMethod) && !_memberFoundInSubclass(propagatedType.element, methodName, t rue, false)) { 5703 } else if (_enableHints && _shouldReportMissingMember(propagatedType, pr opagatedMethod) && !_memberFoundInSubclass(propagatedType.element, methodName, t rue, false)) {
5699 _resolver.reportProxyConditionalErrorForToken(propagatedType.element, HintCode.UNDEFINED_OPERATOR, operator, [methodName, propagatedType.displayName]) ; 5704 if (_doesClassElementHaveProxy(propagatedType.element)) {
5705 _resolver.reportErrorForToken(HintCode.UNDEFINED_OPERATOR, operator, [methodName, propagatedType.displayName]);
5706 }
5700 } 5707 }
5701 } 5708 }
5702 } 5709 }
5703 return null; 5710 return null;
5704 } 5711 }
5705 5712
5706 @override 5713 @override
5707 Object visitBreakStatement(BreakStatement node) { 5714 Object visitBreakStatement(BreakStatement node) {
5708 _lookupLabel(node, node.label); 5715 _lookupLabel(node, node.label);
5709 return null; 5716 return null;
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
6119 } 6126 }
6120 } 6127 }
6121 } 6128 }
6122 generatedWithTypePropagation = true; 6129 generatedWithTypePropagation = true;
6123 } 6130 }
6124 if (errorCode == null) { 6131 if (errorCode == null) {
6125 return null; 6132 return null;
6126 } 6133 }
6127 if (identical(errorCode, StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION)) { 6134 if (identical(errorCode, StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION)) {
6128 _resolver.reportErrorForNode(StaticTypeWarningCode.INVOCATION_OF_NON_FUNCT ION, methodName, [methodName.name]); 6135 _resolver.reportErrorForNode(StaticTypeWarningCode.INVOCATION_OF_NON_FUNCT ION, methodName, [methodName.name]);
6129 } else if (identical(errorCode, CompileTimeErrorCode.UNDEFINED_FUNCTION)) { 6136 } else if (identical(errorCode, StaticTypeWarningCode.UNDEFINED_FUNCTION)) {
6130 _resolver.reportErrorForNode(CompileTimeErrorCode.UNDEFINED_FUNCTION, meth odName, [methodName.name]); 6137 _resolver.reportErrorForNode(StaticTypeWarningCode.UNDEFINED_FUNCTION, met hodName, [methodName.name]);
6131 } else if (identical(errorCode, StaticTypeWarningCode.UNDEFINED_METHOD)) { 6138 } else if (identical(errorCode, StaticTypeWarningCode.UNDEFINED_METHOD)) {
6132 String targetTypeName; 6139 String targetTypeName;
6133 if (target == null) { 6140 if (target == null) {
6134 ClassElement enclosingClass = _resolver.enclosingClass; 6141 ClassElement enclosingClass = _resolver.enclosingClass;
6135 targetTypeName = enclosingClass.displayName; 6142 targetTypeName = enclosingClass.displayName;
6136 ErrorCode proxyErrorCode = (generatedWithTypePropagation ? HintCode.UNDE FINED_METHOD : StaticTypeWarningCode.UNDEFINED_METHOD) as ErrorCode; 6143 ErrorCode proxyErrorCode = (generatedWithTypePropagation ? HintCode.UNDE FINED_METHOD : StaticTypeWarningCode.UNDEFINED_METHOD);
6137 _resolver.reportProxyConditionalErrorForNode(_resolver.enclosingClass, p roxyErrorCode, methodName, [methodName.name, targetTypeName]); 6144 if (_doesClassElementHaveProxy(_resolver.enclosingClass)) {
6145 _resolver.reportErrorForNode(proxyErrorCode, methodName, [methodName.n ame, targetTypeName]);
6146 }
6138 } else { 6147 } else {
6139 // ignore Function "call" 6148 // ignore Function "call"
6140 // (if we are about to create a hint using type propagation, then we can use type 6149 // (if we are about to create a hint using type propagation, then we can use type
6141 // propagation here as well) 6150 // propagation here as well)
6142 DartType targetType = null; 6151 DartType targetType = null;
6143 if (!generatedWithTypePropagation) { 6152 if (!generatedWithTypePropagation) {
6144 targetType = _getStaticType(target); 6153 targetType = _getStaticType(target);
6145 } else { 6154 } else {
6146 // choose the best type 6155 // choose the best type
6147 targetType = _getPropagatedType(target); 6156 targetType = _getPropagatedType(target);
6148 if (targetType == null) { 6157 if (targetType == null) {
6149 targetType = _getStaticType(target); 6158 targetType = _getStaticType(target);
6150 } 6159 }
6151 } 6160 }
6152 if (targetType != null && targetType.isDartCoreFunction && methodName.na me == CALL_METHOD_NAME) { 6161 if (targetType != null && targetType.isDartCoreFunction && methodName.na me == CALL_METHOD_NAME) {
6153 // TODO(brianwilkerson) Can we ever resolve the function being invoked ? 6162 // TODO(brianwilkerson) Can we ever resolve the function being invoked ?
6154 //resolveArgumentsToParameters(node.getArgumentList(), invokedFunction ); 6163 //resolveArgumentsToParameters(node.getArgumentList(), invokedFunction );
6155 return null; 6164 return null;
6156 } 6165 }
6157 targetTypeName = targetType == null ? null : targetType.displayName; 6166 targetTypeName = targetType == null ? null : targetType.displayName;
6158 ErrorCode proxyErrorCode = (generatedWithTypePropagation ? HintCode.UNDE FINED_METHOD : StaticTypeWarningCode.UNDEFINED_METHOD) as ErrorCode; 6167 ErrorCode proxyErrorCode = (generatedWithTypePropagation ? HintCode.UNDE FINED_METHOD : StaticTypeWarningCode.UNDEFINED_METHOD);
6159 _resolver.reportProxyConditionalErrorForNode(targetType.element, proxyEr rorCode, methodName, [methodName.name, targetTypeName]); 6168 if (_doesClassElementHaveProxy(targetType.element)) {
6169 _resolver.reportErrorForNode(proxyErrorCode, methodName, [methodName.n ame, targetTypeName]);
6170 }
6160 } 6171 }
6161 } else if (identical(errorCode, StaticTypeWarningCode.UNDEFINED_SUPER_METHOD )) { 6172 } else if (identical(errorCode, StaticTypeWarningCode.UNDEFINED_SUPER_METHOD )) {
6162 // Generate the type name. 6173 // Generate the type name.
6163 // The error code will never be generated via type propagation 6174 // The error code will never be generated via type propagation
6164 DartType targetType = _getStaticType(target); 6175 DartType targetType = _getStaticType(target);
6165 String targetTypeName = targetType == null ? null : targetType.name; 6176 String targetTypeName = targetType == null ? null : targetType.name;
6166 _resolver.reportErrorForNode(StaticTypeWarningCode.UNDEFINED_SUPER_METHOD, methodName, [methodName.name, targetTypeName]); 6177 _resolver.reportErrorForNode(StaticTypeWarningCode.UNDEFINED_SUPER_METHOD, methodName, [methodName.name, targetTypeName]);
6167 } 6178 }
6168 return null; 6179 return null;
6169 } 6180 }
(...skipping 14 matching lines...) Expand all
6184 Object visitPostfixExpression(PostfixExpression node) { 6195 Object visitPostfixExpression(PostfixExpression node) {
6185 Expression operand = node.operand; 6196 Expression operand = node.operand;
6186 String methodName = _getPostfixOperator(node); 6197 String methodName = _getPostfixOperator(node);
6187 DartType staticType = _getStaticType(operand); 6198 DartType staticType = _getStaticType(operand);
6188 MethodElement staticMethod = _lookUpMethod(operand, staticType, methodName); 6199 MethodElement staticMethod = _lookUpMethod(operand, staticType, methodName);
6189 node.staticElement = staticMethod; 6200 node.staticElement = staticMethod;
6190 DartType propagatedType = _getPropagatedType(operand); 6201 DartType propagatedType = _getPropagatedType(operand);
6191 MethodElement propagatedMethod = _lookUpMethod(operand, propagatedType, meth odName); 6202 MethodElement propagatedMethod = _lookUpMethod(operand, propagatedType, meth odName);
6192 node.propagatedElement = propagatedMethod; 6203 node.propagatedElement = propagatedMethod;
6193 if (_shouldReportMissingMember(staticType, staticMethod)) { 6204 if (_shouldReportMissingMember(staticType, staticMethod)) {
6194 _resolver.reportProxyConditionalErrorForToken(staticType.element, StaticTy peWarningCode.UNDEFINED_OPERATOR, node.operator, [methodName, staticType.display Name]); 6205 if (_doesClassElementHaveProxy(staticType.element)) {
6206 _resolver.reportErrorForToken(StaticTypeWarningCode.UNDEFINED_OPERATOR, node.operator, [methodName, staticType.displayName]);
6207 }
6195 } else if (_enableHints && _shouldReportMissingMember(propagatedType, propag atedMethod) && !_memberFoundInSubclass(propagatedType.element, methodName, true, false)) { 6208 } else if (_enableHints && _shouldReportMissingMember(propagatedType, propag atedMethod) && !_memberFoundInSubclass(propagatedType.element, methodName, true, false)) {
6196 _resolver.reportProxyConditionalErrorForToken(propagatedType.element, Hint Code.UNDEFINED_OPERATOR, node.operator, [methodName, propagatedType.displayName] ); 6209 if (_doesClassElementHaveProxy(propagatedType.element)) {
6210 _resolver.reportErrorForToken(HintCode.UNDEFINED_OPERATOR, node.operator , [methodName, propagatedType.displayName]);
6211 }
6197 } 6212 }
6198 return null; 6213 return null;
6199 } 6214 }
6200 6215
6201 @override 6216 @override
6202 Object visitPrefixedIdentifier(PrefixedIdentifier node) { 6217 Object visitPrefixedIdentifier(PrefixedIdentifier node) {
6203 SimpleIdentifier prefix = node.prefix; 6218 SimpleIdentifier prefix = node.prefix;
6204 SimpleIdentifier identifier = node.identifier; 6219 SimpleIdentifier identifier = node.identifier;
6205 // 6220 //
6206 // First, check to see whether the prefix is really a prefix. 6221 // First, check to see whether the prefix is really a prefix.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
6263 if (operatorType.isUserDefinableOperator || operatorType == sc.TokenType.PLU S_PLUS || operatorType == sc.TokenType.MINUS_MINUS) { 6278 if (operatorType.isUserDefinableOperator || operatorType == sc.TokenType.PLU S_PLUS || operatorType == sc.TokenType.MINUS_MINUS) {
6264 Expression operand = node.operand; 6279 Expression operand = node.operand;
6265 String methodName = _getPrefixOperator(node); 6280 String methodName = _getPrefixOperator(node);
6266 DartType staticType = _getStaticType(operand); 6281 DartType staticType = _getStaticType(operand);
6267 MethodElement staticMethod = _lookUpMethod(operand, staticType, methodName ); 6282 MethodElement staticMethod = _lookUpMethod(operand, staticType, methodName );
6268 node.staticElement = staticMethod; 6283 node.staticElement = staticMethod;
6269 DartType propagatedType = _getPropagatedType(operand); 6284 DartType propagatedType = _getPropagatedType(operand);
6270 MethodElement propagatedMethod = _lookUpMethod(operand, propagatedType, me thodName); 6285 MethodElement propagatedMethod = _lookUpMethod(operand, propagatedType, me thodName);
6271 node.propagatedElement = propagatedMethod; 6286 node.propagatedElement = propagatedMethod;
6272 if (_shouldReportMissingMember(staticType, staticMethod)) { 6287 if (_shouldReportMissingMember(staticType, staticMethod)) {
6273 _resolver.reportProxyConditionalErrorForToken(staticType.element, Static TypeWarningCode.UNDEFINED_OPERATOR, operator, [methodName, staticType.displayNam e]); 6288 if (_doesClassElementHaveProxy(staticType.element)) {
6289 _resolver.reportErrorForToken(StaticTypeWarningCode.UNDEFINED_OPERATOR , operator, [methodName, staticType.displayName]);
6290 }
6274 } else if (_enableHints && _shouldReportMissingMember(propagatedType, prop agatedMethod) && !_memberFoundInSubclass(propagatedType.element, methodName, tru e, false)) { 6291 } else if (_enableHints && _shouldReportMissingMember(propagatedType, prop agatedMethod) && !_memberFoundInSubclass(propagatedType.element, methodName, tru e, false)) {
6275 _resolver.reportProxyConditionalErrorForToken(propagatedType.element, Hi ntCode.UNDEFINED_OPERATOR, operator, [methodName, propagatedType.displayName]); 6292 if (_doesClassElementHaveProxy(propagatedType.element)) {
6293 _resolver.reportErrorForToken(HintCode.UNDEFINED_OPERATOR, operator, [ methodName, propagatedType.displayName]);
6294 }
6276 } 6295 }
6277 } 6296 }
6278 return null; 6297 return null;
6279 } 6298 }
6280 6299
6281 @override 6300 @override
6282 Object visitPropertyAccess(PropertyAccess node) { 6301 Object visitPropertyAccess(PropertyAccess node) {
6283 Expression target = node.realTarget; 6302 Expression target = node.realTarget;
6284 if (target is SuperExpression && !_isSuperInValidContext(target)) { 6303 if (target is SuperExpression && !_isSuperInValidContext(target)) {
6285 return null; 6304 return null;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
6359 _resolver.reportErrorForNode(CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME , node, []); 6378 _resolver.reportErrorForNode(CompileTimeErrorCode.INVALID_CONSTRUCTOR_NAME , node, []);
6360 element = null; 6379 element = null;
6361 } else if (element == null || (element is PrefixElement && !_isValidAsPrefix (node))) { 6380 } else if (element == null || (element is PrefixElement && !_isValidAsPrefix (node))) {
6362 // TODO(brianwilkerson) Recover from this error. 6381 // TODO(brianwilkerson) Recover from this error.
6363 if (_isConstructorReturnType(node)) { 6382 if (_isConstructorReturnType(node)) {
6364 _resolver.reportErrorForNode(CompileTimeErrorCode.INVALID_CONSTRUCTOR_NA ME, node, []); 6383 _resolver.reportErrorForNode(CompileTimeErrorCode.INVALID_CONSTRUCTOR_NA ME, node, []);
6365 } else if (node.parent is Annotation) { 6384 } else if (node.parent is Annotation) {
6366 Annotation annotation = node.parent as Annotation; 6385 Annotation annotation = node.parent as Annotation;
6367 _resolver.reportErrorForNode(CompileTimeErrorCode.INVALID_ANNOTATION, an notation, []); 6386 _resolver.reportErrorForNode(CompileTimeErrorCode.INVALID_ANNOTATION, an notation, []);
6368 } else { 6387 } else {
6369 _resolver.reportProxyConditionalErrorForNode(_resolver.enclosingClass, S taticWarningCode.UNDEFINED_IDENTIFIER, node, [node.name]); 6388 if (_doesClassElementHaveProxy(_resolver.enclosingClass)) {
6389 _resolver.reportErrorForNode(StaticWarningCode.UNDEFINED_IDENTIFIER, n ode, [node.name]);
6390 }
6370 } 6391 }
6371 } 6392 }
6372 node.staticElement = element; 6393 node.staticElement = element;
6373 if (node.inSetterContext() && node.inGetterContext() && enclosingClass != nu ll) { 6394 if (node.inSetterContext() && node.inGetterContext() && enclosingClass != nu ll) {
6374 InterfaceType enclosingType = enclosingClass.type; 6395 InterfaceType enclosingType = enclosingClass.type;
6375 AuxiliaryElements auxiliaryElements = new AuxiliaryElements(_lookUpGetter( null, enclosingType, node.name), null); 6396 AuxiliaryElements auxiliaryElements = new AuxiliaryElements(_lookUpGetter( null, enclosingType, node.name), null);
6376 node.auxiliaryElements = auxiliaryElements; 6397 node.auxiliaryElements = auxiliaryElements;
6377 } 6398 }
6378 // 6399 //
6379 // Validate annotation element. 6400 // Validate annotation element.
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
6513 } 6534 }
6514 } else if (element is VariableElement) { 6535 } else if (element is VariableElement) {
6515 DartType variableType = element.type; 6536 DartType variableType = element.type;
6516 if (!_isExecutableType(variableType)) { 6537 if (!_isExecutableType(variableType)) {
6517 return StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION; 6538 return StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION;
6518 } 6539 }
6519 } else { 6540 } else {
6520 if (target == null) { 6541 if (target == null) {
6521 ClassElement enclosingClass = _resolver.enclosingClass; 6542 ClassElement enclosingClass = _resolver.enclosingClass;
6522 if (enclosingClass == null) { 6543 if (enclosingClass == null) {
6523 return CompileTimeErrorCode.UNDEFINED_FUNCTION; 6544 return StaticTypeWarningCode.UNDEFINED_FUNCTION;
6524 } else if (element == null) { 6545 } else if (element == null) {
6525 // Proxy-conditional warning, based on state of resolver.getEnclosin gClass() 6546 // Proxy-conditional warning, based on state of resolver.getEnclosin gClass()
6526 return StaticTypeWarningCode.UNDEFINED_METHOD; 6547 return StaticTypeWarningCode.UNDEFINED_METHOD;
6527 } else { 6548 } else {
6528 return StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION; 6549 return StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION;
6529 } 6550 }
6530 } else { 6551 } else {
6531 DartType targetType; 6552 DartType targetType;
6532 if (useStaticContext) { 6553 if (useStaticContext) {
6533 targetType = _getStaticType(target); 6554 targetType = _getStaticType(target);
6534 } else { 6555 } else {
6535 // Compute and use the propagated type, if it is null, then it may b e the case that 6556 // Compute and use the propagated type, if it is null, then it may b e the case that
6536 // static type is some type, in which the static type should be used . 6557 // static type is some type, in which the static type should be used .
6537 targetType = target.bestType; 6558 targetType = target.bestType;
6538 } 6559 }
6539 if (targetType == null) { 6560 if (targetType == null) {
6540 return CompileTimeErrorCode.UNDEFINED_FUNCTION; 6561 return StaticTypeWarningCode.UNDEFINED_FUNCTION;
6541 } else if (!targetType.isDynamic && !targetType.isBottom) { 6562 } else if (!targetType.isDynamic && !targetType.isBottom) {
6542 // Proxy-conditional warning, based on state of targetType.getElemen t() 6563 // Proxy-conditional warning, based on state of targetType.getElemen t()
6543 return StaticTypeWarningCode.UNDEFINED_METHOD; 6564 return StaticTypeWarningCode.UNDEFINED_METHOD;
6544 } 6565 }
6545 } 6566 }
6546 } 6567 }
6547 } 6568 }
6548 return null; 6569 return null;
6549 } 6570 }
6550 6571
6551 /** 6572 /**
6552 * Check that the for some index expression that the method element was resolv ed, otherwise a 6573 * Check that the for some index expression that the method element was resolv ed, otherwise a
6553 * [StaticWarningCode#UNDEFINED_OPERATOR] is generated. 6574 * [StaticWarningCode#UNDEFINED_OPERATOR] is generated.
6554 * 6575 *
6555 * @param node the index expression to resolve 6576 * @param node the index expression to resolve
6556 * @param target the target of the expression 6577 * @param target the target of the expression
6557 * @param methodName the name of the operator associated with the context of u sing of the given 6578 * @param methodName the name of the operator associated with the context of u sing of the given
6558 * index expression 6579 * index expression
6559 * @return `true` if and only if an error code is generated on the passed node 6580 * @return `true` if and only if an error code is generated on the passed node
6560 */ 6581 */
6561 bool _checkForUndefinedIndexOperator(IndexExpression node, Expression target, String methodName, MethodElement staticMethod, MethodElement propagatedMethod, D artType staticType, DartType propagatedType) { 6582 bool _checkForUndefinedIndexOperator(IndexExpression node, Expression target, String methodName, MethodElement staticMethod, MethodElement propagatedMethod, D artType staticType, DartType propagatedType) {
6562 bool shouldReportMissingMember_static = _shouldReportMissingMember(staticTyp e, staticMethod); 6583 bool shouldReportMissingMember_static = _shouldReportMissingMember(staticTyp e, staticMethod);
6563 bool shouldReportMissingMember_propagated = !shouldReportMissingMember_stati c && _enableHints && _shouldReportMissingMember(propagatedType, propagatedMethod ) && !_memberFoundInSubclass(propagatedType.element, methodName, true, false); 6584 bool shouldReportMissingMember_propagated = !shouldReportMissingMember_stati c && _enableHints && _shouldReportMissingMember(propagatedType, propagatedMethod ) && !_memberFoundInSubclass(propagatedType.element, methodName, true, false);
6564 if (shouldReportMissingMember_static || shouldReportMissingMember_propagated ) { 6585 if (shouldReportMissingMember_static || shouldReportMissingMember_propagated ) {
6565 sc.Token leftBracket = node.leftBracket; 6586 sc.Token leftBracket = node.leftBracket;
6566 sc.Token rightBracket = node.rightBracket; 6587 sc.Token rightBracket = node.rightBracket;
6567 ErrorCode errorCode = (shouldReportMissingMember_static ? StaticTypeWarnin gCode.UNDEFINED_OPERATOR : HintCode.UNDEFINED_OPERATOR) as ErrorCode; 6588 ErrorCode errorCode = (shouldReportMissingMember_static ? StaticTypeWarnin gCode.UNDEFINED_OPERATOR : HintCode.UNDEFINED_OPERATOR);
6568 if (leftBracket == null || rightBracket == null) { 6589 if (leftBracket == null || rightBracket == null) {
6569 _resolver.reportProxyConditionalErrorForNode(shouldReportMissingMember_s tatic ? staticType.element : propagatedType.element, errorCode, node, [ 6590 if (_doesClassElementHaveProxy(shouldReportMissingMember_static ? static Type.element : propagatedType.element)) {
6570 methodName, 6591 _resolver.reportErrorForNode(errorCode, node, [
6571 shouldReportMissingMember_static ? staticType.displayName : propagat edType.displayName]); 6592 methodName,
6593 shouldReportMissingMember_static ? staticType.displayName : propag atedType.displayName]);
6594 }
6572 } else { 6595 } else {
6573 int offset = leftBracket.offset; 6596 int offset = leftBracket.offset;
6574 int length = rightBracket.offset - offset + 1; 6597 int length = rightBracket.offset - offset + 1;
6575 _resolver.reportProxyConditionalErrorForOffset(shouldReportMissingMember _static ? staticType.element : propagatedType.element, errorCode, offset, length , [ 6598 if (_doesClassElementHaveProxy(shouldReportMissingMember_static ? static Type.element : propagatedType.element)) {
6576 methodName, 6599 _resolver.reportErrorForOffset(errorCode, offset, length, [
6577 shouldReportMissingMember_static ? staticType.displayName : propagat edType.displayName]); 6600 methodName,
6601 shouldReportMissingMember_static ? staticType.displayName : propag atedType.displayName]);
6602 }
6578 } 6603 }
6579 return true; 6604 return true;
6580 } 6605 }
6581 return false; 6606 return false;
6582 } 6607 }
6583 6608
6584 /** 6609 /**
6585 * Given a list of arguments and the element that will be invoked using those argument, compute 6610 * Given a list of arguments and the element that will be invoked using those argument, compute
6586 * the list of parameters that correspond to the list of arguments. Return the parameters that 6611 * the list of parameters that correspond to the list of arguments. Return the parameters that
6587 * correspond to the arguments, or `null` if no correspondence could be comput ed. 6612 * correspond to the arguments, or `null` if no correspondence could be comput ed.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
6640 */ 6665 */
6641 Element _convertSetterToGetter(Element element) { 6666 Element _convertSetterToGetter(Element element) {
6642 // TODO(brianwilkerson) Determine whether and why the element could ever be a setter. 6667 // TODO(brianwilkerson) Determine whether and why the element could ever be a setter.
6643 if (element is PropertyAccessorElement) { 6668 if (element is PropertyAccessorElement) {
6644 return element.variable.getter; 6669 return element.variable.getter;
6645 } 6670 }
6646 return element; 6671 return element;
6647 } 6672 }
6648 6673
6649 /** 6674 /**
6675 * Return `true` iff the passed [Element] is a [ClassElement] and either has, or
6676 * in that is or inherits proxy.
6677 *
6678 * @param element the enclosing element
6679 * @return `true` iff the passed [Element] is a [ClassElement] and either has,
6680 * or in that is or inherits proxy
6681 * @see ClassElement#isOrInheritsProxy()
6682 */
6683 bool _doesClassElementHaveProxy(Element element) {
6684 if (element is ClassElement) {
6685 return !element.isOrInheritsProxy;
6686 }
6687 return true;
6688 }
6689
6690 /**
6650 * Look for any declarations of the given identifier that are imported using a prefix. Return the 6691 * Look for any declarations of the given identifier that are imported using a prefix. Return the
6651 * element that was found, or `null` if the name is not imported using a prefi x. 6692 * element that was found, or `null` if the name is not imported using a prefi x.
6652 * 6693 *
6653 * @param identifier the identifier that might have been imported using a pref ix 6694 * @param identifier the identifier that might have been imported using a pref ix
6654 * @return the element that was found 6695 * @return the element that was found
6655 */ 6696 */
6656 Element _findImportWithoutPrefix(SimpleIdentifier identifier) { 6697 Element _findImportWithoutPrefix(SimpleIdentifier identifier) {
6657 Element element = null; 6698 Element element = null;
6658 Scope nameScope = _resolver.nameScope; 6699 Scope nameScope = _resolver.nameScope;
6659 for (ImportElement importElement in _definingLibrary.imports) { 6700 for (ImportElement importElement in _definingLibrary.imports) {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
6743 * operator '()'. 6784 * operator '()'.
6744 * 6785 *
6745 * @param type the type being tested 6786 * @param type the type being tested
6746 * @return `true` if the given type represents an object that could be invoked 6787 * @return `true` if the given type represents an object that could be invoked
6747 */ 6788 */
6748 bool _isExecutableType(DartType type) { 6789 bool _isExecutableType(DartType type) {
6749 if (type.isDynamic || (type is FunctionType) || type.isDartCoreFunction || t ype.isObject) { 6790 if (type.isDynamic || (type is FunctionType) || type.isDartCoreFunction || t ype.isObject) {
6750 return true; 6791 return true;
6751 } else if (type is InterfaceType) { 6792 } else if (type is InterfaceType) {
6752 ClassElement classElement = type.element; 6793 ClassElement classElement = type.element;
6794 // 16078 from Gilad: If the type is a Functor with the @proxy annotation, treat it as an
6795 // executable type.
6796 // example code: NonErrorResolverTest.test_invocationOfNonFunction_proxyOn FunctionClass()
6797 if (classElement.isProxy && type.isSubtypeOf(_resolver.typeProvider.functi onType)) {
6798 return true;
6799 }
6753 MethodElement methodElement = classElement.lookUpMethod(CALL_METHOD_NAME, _definingLibrary); 6800 MethodElement methodElement = classElement.lookUpMethod(CALL_METHOD_NAME, _definingLibrary);
6754 return methodElement != null; 6801 return methodElement != null;
6755 } 6802 }
6756 return false; 6803 return false;
6757 } 6804 }
6758 6805
6759 /** 6806 /**
6760 * @return `true` iff current enclosing function is constant constructor decla ration. 6807 * @return `true` iff current enclosing function is constant constructor decla ration.
6761 */ 6808 */
6762 bool get isInConstConstructor { 6809 bool get isInConstConstructor {
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
7393 List<ParameterElement> resolvedParameters = new List<ParameterElement>(argum entCount); 7440 List<ParameterElement> resolvedParameters = new List<ParameterElement>(argum entCount);
7394 int positionalArgumentCount = 0; 7441 int positionalArgumentCount = 0;
7395 Set<String> usedNames = new Set<String>(); 7442 Set<String> usedNames = new Set<String>();
7396 for (int i = 0; i < argumentCount; i++) { 7443 for (int i = 0; i < argumentCount; i++) {
7397 Expression argument = arguments[i]; 7444 Expression argument = arguments[i];
7398 if (argument is NamedExpression) { 7445 if (argument is NamedExpression) {
7399 SimpleIdentifier nameNode = argument.name.label; 7446 SimpleIdentifier nameNode = argument.name.label;
7400 String name = nameNode.name; 7447 String name = nameNode.name;
7401 ParameterElement element = namedParameters[name]; 7448 ParameterElement element = namedParameters[name];
7402 if (element == null) { 7449 if (element == null) {
7403 ErrorCode errorCode = (reportError ? CompileTimeErrorCode.UNDEFINED_NA MED_PARAMETER : StaticWarningCode.UNDEFINED_NAMED_PARAMETER) as ErrorCode; 7450 ErrorCode errorCode = (reportError ? CompileTimeErrorCode.UNDEFINED_NA MED_PARAMETER : StaticWarningCode.UNDEFINED_NAMED_PARAMETER);
7404 _resolver.reportErrorForNode(errorCode, nameNode, [name]); 7451 _resolver.reportErrorForNode(errorCode, nameNode, [name]);
7405 } else { 7452 } else {
7406 resolvedParameters[i] = element; 7453 resolvedParameters[i] = element;
7407 nameNode.staticElement = element; 7454 nameNode.staticElement = element;
7408 } 7455 }
7409 if (!usedNames.add(name)) { 7456 if (!usedNames.add(name)) {
7410 _resolver.reportErrorForNode(CompileTimeErrorCode.DUPLICATE_NAMED_ARGU MENT, nameNode, [name]); 7457 _resolver.reportErrorForNode(CompileTimeErrorCode.DUPLICATE_NAMED_ARGU MENT, nameNode, [name]);
7411 } 7458 }
7412 } else { 7459 } else {
7413 positionalArgumentCount++; 7460 positionalArgumentCount++;
7414 if (unnamedIndex < unnamedParameterCount) { 7461 if (unnamedIndex < unnamedParameterCount) {
7415 resolvedParameters[i] = unnamedParameters[unnamedIndex++]; 7462 resolvedParameters[i] = unnamedParameters[unnamedIndex++];
7416 } 7463 }
7417 } 7464 }
7418 } 7465 }
7419 if (positionalArgumentCount < requiredParameters.length) { 7466 if (positionalArgumentCount < requiredParameters.length) {
7420 ErrorCode errorCode = (reportError ? CompileTimeErrorCode.NOT_ENOUGH_REQUI RED_ARGUMENTS : StaticWarningCode.NOT_ENOUGH_REQUIRED_ARGUMENTS) as ErrorCode; 7467 ErrorCode errorCode = (reportError ? CompileTimeErrorCode.NOT_ENOUGH_REQUI RED_ARGUMENTS : StaticWarningCode.NOT_ENOUGH_REQUIRED_ARGUMENTS);
7421 _resolver.reportErrorForNode(errorCode, argumentList, [requiredParameters. length, positionalArgumentCount]); 7468 _resolver.reportErrorForNode(errorCode, argumentList, [requiredParameters. length, positionalArgumentCount]);
7422 } else if (positionalArgumentCount > unnamedParameterCount) { 7469 } else if (positionalArgumentCount > unnamedParameterCount) {
7423 ErrorCode errorCode = (reportError ? CompileTimeErrorCode.EXTRA_POSITIONAL _ARGUMENTS : StaticWarningCode.EXTRA_POSITIONAL_ARGUMENTS) as ErrorCode; 7470 ErrorCode errorCode = (reportError ? CompileTimeErrorCode.EXTRA_POSITIONAL _ARGUMENTS : StaticWarningCode.EXTRA_POSITIONAL_ARGUMENTS);
7424 _resolver.reportErrorForNode(errorCode, argumentList, [unnamedParameterCou nt, positionalArgumentCount]); 7471 _resolver.reportErrorForNode(errorCode, argumentList, [unnamedParameterCou nt, positionalArgumentCount]);
7425 } 7472 }
7426 return resolvedParameters; 7473 return resolvedParameters;
7427 } 7474 }
7428 7475
7429 /** 7476 /**
7430 * Resolve the names in the given combinators in the scope of the given librar y. 7477 * Resolve the names in the given combinators in the scope of the given librar y.
7431 * 7478 *
7432 * @param library the library that defines the names 7479 * @param library the library that defines the names
7433 * @param combinators the combinators containing the names to be resolved 7480 * @param combinators the combinators containing the names to be resolved
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
7613 // If we are about to generate the hint (propagated version of this warning) , then check 7660 // If we are about to generate the hint (propagated version of this warning) , then check
7614 // that the member is not in a subtype of the propagated type. 7661 // that the member is not in a subtype of the propagated type.
7615 if (shouldReportMissingMember_propagated) { 7662 if (shouldReportMissingMember_propagated) {
7616 if (_memberFoundInSubclass(propagatedType.element, propertyName.name, fals e, true)) { 7663 if (_memberFoundInSubclass(propagatedType.element, propertyName.name, fals e, true)) {
7617 shouldReportMissingMember_propagated = false; 7664 shouldReportMissingMember_propagated = false;
7618 } 7665 }
7619 } 7666 }
7620 if (shouldReportMissingMember_static || shouldReportMissingMember_propagated ) { 7667 if (shouldReportMissingMember_static || shouldReportMissingMember_propagated ) {
7621 if (staticType.isVoid) { 7668 if (staticType.isVoid) {
7622 if (propertyName.inSetterContext()) { 7669 if (propertyName.inSetterContext()) {
7623 ErrorCode errorCode = (shouldReportMissingMember_static ? StaticTypeWa rningCode.UNDEFINED_SETTER : HintCode.UNDEFINED_SETTER) as ErrorCode; 7670 ErrorCode errorCode = (shouldReportMissingMember_static ? StaticTypeWa rningCode.UNDEFINED_SETTER : HintCode.UNDEFINED_SETTER);
7624 _resolver.reportErrorForNode(errorCode, propertyName, [propertyName.na me, staticType.displayName]); 7671 _resolver.reportErrorForNode(errorCode, propertyName, [propertyName.na me, staticType.displayName]);
7625 } else if (propertyName.inGetterContext()) { 7672 } else if (propertyName.inGetterContext()) {
7626 ErrorCode errorCode = (shouldReportMissingMember_static ? StaticTypeWa rningCode.UNDEFINED_GETTER : HintCode.UNDEFINED_GETTER) as ErrorCode; 7673 ErrorCode errorCode = (shouldReportMissingMember_static ? StaticTypeWa rningCode.UNDEFINED_GETTER : HintCode.UNDEFINED_GETTER);
7627 _resolver.reportErrorForNode(errorCode, propertyName, [propertyName.na me, staticType.displayName]); 7674 _resolver.reportErrorForNode(errorCode, propertyName, [propertyName.na me, staticType.displayName]);
7628 } else { 7675 } else {
7629 _resolver.reportErrorForNode(StaticWarningCode.UNDEFINED_IDENTIFIER, p ropertyName, [propertyName.name]); 7676 _resolver.reportErrorForNode(StaticWarningCode.UNDEFINED_IDENTIFIER, p ropertyName, [propertyName.name]);
7630 } 7677 }
7631 } 7678 }
7632 Element staticOrPropagatedEnclosingElt = shouldReportMissingMember_static ? staticType.element : propagatedType.element; 7679 Element staticOrPropagatedEnclosingElt = shouldReportMissingMember_static ? staticType.element : propagatedType.element;
7633 if (staticOrPropagatedEnclosingElt != null) { 7680 if (staticOrPropagatedEnclosingElt != null) {
7634 bool isStaticProperty = _isStatic(staticOrPropagatedEnclosingElt); 7681 bool isStaticProperty = _isStatic(staticOrPropagatedEnclosingElt);
7635 if (propertyName.inSetterContext()) { 7682 if (propertyName.inSetterContext()) {
7636 if (isStaticProperty) { 7683 if (isStaticProperty) {
7637 ErrorCode errorCode = (shouldReportMissingMember_static ? StaticWarn ingCode.UNDEFINED_SETTER : HintCode.UNDEFINED_SETTER) as ErrorCode; 7684 ErrorCode errorCode = (shouldReportMissingMember_static ? StaticWarn ingCode.UNDEFINED_SETTER : HintCode.UNDEFINED_SETTER);
7638 _resolver.reportProxyConditionalErrorForNode(staticOrPropagatedEnclo singElt, errorCode, propertyName, [ 7685 if (_doesClassElementHaveProxy(staticOrPropagatedEnclosingElt)) {
7639 propertyName.name, 7686 _resolver.reportErrorForNode(errorCode, propertyName, [
7640 staticOrPropagatedEnclosingElt.displayName]); 7687 propertyName.name,
7688 staticOrPropagatedEnclosingElt.displayName]);
7689 }
7641 } else { 7690 } else {
7642 ErrorCode errorCode = (shouldReportMissingMember_static ? StaticType WarningCode.UNDEFINED_SETTER : HintCode.UNDEFINED_SETTER) as ErrorCode; 7691 ErrorCode errorCode = (shouldReportMissingMember_static ? StaticType WarningCode.UNDEFINED_SETTER : HintCode.UNDEFINED_SETTER);
7643 _resolver.reportProxyConditionalErrorForNode(staticOrPropagatedEnclo singElt, errorCode, propertyName, [ 7692 if (_doesClassElementHaveProxy(staticOrPropagatedEnclosingElt)) {
7644 propertyName.name, 7693 _resolver.reportErrorForNode(errorCode, propertyName, [
7645 staticOrPropagatedEnclosingElt.displayName]); 7694 propertyName.name,
7695 staticOrPropagatedEnclosingElt.displayName]);
7696 }
7646 } 7697 }
7647 } else if (propertyName.inGetterContext()) { 7698 } else if (propertyName.inGetterContext()) {
7648 if (isStaticProperty) { 7699 if (isStaticProperty) {
7649 ErrorCode errorCode = (shouldReportMissingMember_static ? StaticWarn ingCode.UNDEFINED_GETTER : HintCode.UNDEFINED_GETTER) as ErrorCode; 7700 ErrorCode errorCode = (shouldReportMissingMember_static ? StaticWarn ingCode.UNDEFINED_GETTER : HintCode.UNDEFINED_GETTER);
7650 _resolver.reportProxyConditionalErrorForNode(staticOrPropagatedEnclo singElt, errorCode, propertyName, [ 7701 if (_doesClassElementHaveProxy(staticOrPropagatedEnclosingElt)) {
7651 propertyName.name, 7702 _resolver.reportErrorForNode(errorCode, propertyName, [
7652 staticOrPropagatedEnclosingElt.displayName]); 7703 propertyName.name,
7704 staticOrPropagatedEnclosingElt.displayName]);
7705 }
7653 } else { 7706 } else {
7654 ErrorCode errorCode = (shouldReportMissingMember_static ? StaticType WarningCode.UNDEFINED_GETTER : HintCode.UNDEFINED_GETTER) as ErrorCode; 7707 ErrorCode errorCode = (shouldReportMissingMember_static ? StaticType WarningCode.UNDEFINED_GETTER : HintCode.UNDEFINED_GETTER);
7655 _resolver.reportProxyConditionalErrorForNode(staticOrPropagatedEnclo singElt, errorCode, propertyName, [ 7708 if (_doesClassElementHaveProxy(staticOrPropagatedEnclosingElt)) {
7656 propertyName.name, 7709 _resolver.reportErrorForNode(errorCode, propertyName, [
7657 staticOrPropagatedEnclosingElt.displayName]); 7710 propertyName.name,
7711 staticOrPropagatedEnclosingElt.displayName]);
7712 }
7658 } 7713 }
7659 } else { 7714 } else {
7660 _resolver.reportProxyConditionalErrorForNode(staticOrPropagatedEnclosi ngElt, StaticWarningCode.UNDEFINED_IDENTIFIER, propertyName, [propertyName.name] ); 7715 if (_doesClassElementHaveProxy(staticOrPropagatedEnclosingElt)) {
7716 _resolver.reportErrorForNode(StaticWarningCode.UNDEFINED_IDENTIFIER, propertyName, [propertyName.name]);
7717 }
7661 } 7718 }
7662 } 7719 }
7663 } 7720 }
7664 } 7721 }
7665 7722
7666 /** 7723 /**
7667 * Resolve the given simple identifier if possible. Return the element to whic h it could be 7724 * Resolve the given simple identifier if possible. Return the element to whic h it could be
7668 * resolved, or `null` if it could not be resolved. This does not record the r esults of the 7725 * resolved, or `null` if it could not be resolved. This does not record the r esults of the
7669 * resolution. 7726 * resolution.
7670 * 7727 *
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
7952 return node.element; 8009 return node.element;
7953 } else if (node is CompilationUnit) { 8010 } else if (node is CompilationUnit) {
7954 return node.element; 8011 return node.element;
7955 } 8012 }
7956 return null; 8013 return null;
7957 } 8014 }
7958 8015
7959 void _resolveReferences(AstNode node, Scope scope) { 8016 void _resolveReferences(AstNode node, Scope scope) {
7960 ResolverVisitor visitor = new ResolverVisitor.con3(_definingLibrary, _source , _typeProvider, scope, _errorListener); 8017 ResolverVisitor visitor = new ResolverVisitor.con3(_definingLibrary, _source , _typeProvider, scope, _errorListener);
7961 node.accept(visitor); 8018 node.accept(visitor);
7962 for (ProxyConditionalAnalysisError conditionalCode in visitor.proxyCondition alAnalysisErrors) {
7963 if (conditionalCode.shouldIncludeErrorCode()) {
7964 visitor.reportError(conditionalCode.analysisError);
7965 }
7966 }
7967 } 8019 }
7968 8020
7969 void _resolveTypes(AstNode node, Scope scope) { 8021 void _resolveTypes(AstNode node, Scope scope) {
7970 TypeResolverVisitor visitor = new TypeResolverVisitor.con3(_definingLibrary, _source, _typeProvider, scope, _errorListener); 8022 TypeResolverVisitor visitor = new TypeResolverVisitor.con3(_definingLibrary, _source, _typeProvider, scope, _errorListener);
7971 node.accept(visitor); 8023 node.accept(visitor);
7972 } 8024 }
7973 8025
7974 void _resolveVariables(AstNode node, Scope scope) { 8026 void _resolveVariables(AstNode node, Scope scope) {
7975 VariableResolverVisitor visitor = new VariableResolverVisitor.con2(_defining Library, _source, _typeProvider, scope, _errorListener); 8027 VariableResolverVisitor visitor = new VariableResolverVisitor.con2(_defining Library, _source, _typeProvider, scope, _errorListener);
7976 node.accept(visitor); 8028 node.accept(visitor);
7977 } 8029 }
7978 } 8030 }
7979 8031
7980 /** 8032 /**
7981 * Instances of the class `InheritanceManager` manage the knowledge of where cla ss members 8033 * Instances of the class `InheritanceManager` manage the knowledge of where cla ss members
7982 * (methods, getters & setters) are inherited from. 8034 * (methods, getters & setters) are inherited from.
7983 */ 8035 */
7984 class InheritanceManager { 8036 class InheritanceManager {
7985 /** 8037 /**
7986 * Given some array of [ExecutableElement]s, this method creates a synthetic e lement as 8038 * Given some array of [ExecutableElement]s, this method creates a synthetic e lement as
7987 * described in the Superinterfaces section of Inheritance and Overriding. 8039 * described in 8.1.1:
7988 * 8040 *
7989 * TODO (jwren) Copy contents from the Spec into this javadoc. 8041 * Let <i>numberOfPositionals</i>(<i>f</i>) denote the number of positional pa rameters of a
8042 * function <i>f</i>, and let <i>numberOfRequiredParams</i>(<i>f</i>) denote t he number of
8043 * required parameters of a function <i>f</i>. Furthermore, let <i>s</i> denot e the set of all
8044 * named parameters of the <i>m<sub>1</sub>, &hellip;, m<sub>k</sub></i>. Then let
8045 * * <i>h = max(numberOfPositionals(m<sub>i</sub>)),</i>
8046 * * <i>r = min(numberOfRequiredParams(m<sub>i</sub>)), for all <i>i</i>, 1 <= i <= k.</i>
8047 * If <i>r <= h</i> then <i>I</i> has a method named <i>n</i>, with <i>r</i> r equired parameters
8048 * of type <b>dynamic</b>, <i>h</i> positional parameters of type <b>dynamic</ b>, named parameters
8049 * <i>s</i> of type <b>dynamic</b> and return type <b>dynamic</b>.
7990 * 8050 *
7991 * TODO (jwren) Associate a propagated type to the synthetic method element us ing least upper 8051 * TODO (jwren) Associate a propagated type to the synthetic method element us ing least upper
7992 * bound calls 8052 * bounds instead of dynamic
7993 */ 8053 */
7994 static ExecutableElement _computeMergedExecutableElement(List<ExecutableElemen t> elementArrayToMerge) { 8054 static ExecutableElement _computeMergedExecutableElement(List<ExecutableElemen t> elementArrayToMerge) {
7995 int h = _getNumOfPositionalParameters(elementArrayToMerge[0]); 8055 int h = _getNumOfPositionalParameters(elementArrayToMerge[0]);
7996 int r = _getNumOfRequiredParameters(elementArrayToMerge[0]); 8056 int r = _getNumOfRequiredParameters(elementArrayToMerge[0]);
7997 Set<String> namedParametersList = new Set<String>(); 8057 Set<String> namedParametersList = new Set<String>();
7998 for (int i = 1; i < elementArrayToMerge.length; i++) { 8058 for (int i = 1; i < elementArrayToMerge.length; i++) {
7999 ExecutableElement element = elementArrayToMerge[i]; 8059 ExecutableElement element = elementArrayToMerge[i];
8000 int numOfPositionalParams = _getNumOfPositionalParameters(element); 8060 int numOfPositionalParams = _getNumOfPositionalParameters(element);
8001 if (h < numOfPositionalParams) { 8061 if (h < numOfPositionalParams) {
8002 h = numOfPositionalParams; 8062 h = numOfPositionalParams;
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after
8626 } 8686 }
8627 if (!alreadyInList) { 8687 if (!alreadyInList) {
8628 list.add(newExecutableElementEntry); 8688 list.add(newExecutableElementEntry);
8629 } 8689 }
8630 } 8690 }
8631 } 8691 }
8632 } 8692 }
8633 // 8693 //
8634 // Loop through the entries in the unionMap, adding them to the resultMap ap propriately. 8694 // Loop through the entries in the unionMap, adding them to the resultMap ap propriately.
8635 // 8695 //
8636 for (MapIterator<String, List<ExecutableElement>> iter = SingleMapIterator.f orMap(unionMap); iter.moveNext();) { 8696 for (MapEntry<String, List<ExecutableElement>> entry in getMapEntrySet(union Map)) {
8637 String key = iter.key; 8697 String key = entry.getKey();
8638 List<ExecutableElement> list = iter.value; 8698 List<ExecutableElement> list = entry.getValue();
8639 int numOfEltsWithMatchingNames = list.length; 8699 int numOfEltsWithMatchingNames = list.length;
8640 if (numOfEltsWithMatchingNames == 1) { 8700 if (numOfEltsWithMatchingNames == 1) {
8641 // 8701 //
8642 // Example: class A inherits only 1 method named 'm'. Since it is the o nly such method, it 8702 // Example: class A inherits only 1 method named 'm'. Since it is the o nly such method, it
8643 // is inherited. 8703 // is inherited.
8644 // Another example: class A inherits 2 methods named 'm' from 2 differen t interfaces, but 8704 // Another example: class A inherits 2 methods named 'm' from 2 differen t interfaces, but
8645 // they both have the same signature, so it is the method inherited. 8705 // they both have the same signature, so it is the method inherited.
8646 // 8706 //
8647 resultMap.put(key, list[0]); 8707 resultMap.put(key, list[0]);
8648 } else { 8708 } else {
(...skipping 1470 matching lines...) Expand 10 before | Expand all | Expand 10 after
10119 * the library cannot be analyzed 10179 * the library cannot be analyzed
10120 */ 10180 */
10121 void _resolveReferencesAndTypesInLibrary(Library library) { 10181 void _resolveReferencesAndTypesInLibrary(Library library) {
10122 TimeCounter_TimeCounterHandle timeCounter = PerformanceStatistics.resolve.st art(); 10182 TimeCounter_TimeCounterHandle timeCounter = PerformanceStatistics.resolve.st art();
10123 try { 10183 try {
10124 for (Source source in library.compilationUnitSources) { 10184 for (Source source in library.compilationUnitSources) {
10125 CompilationUnit ast = library.getAST(source); 10185 CompilationUnit ast = library.getAST(source);
10126 ast.accept(new VariableResolverVisitor.con1(library, source, _typeProvid er)); 10186 ast.accept(new VariableResolverVisitor.con1(library, source, _typeProvid er));
10127 ResolverVisitor visitor = new ResolverVisitor.con1(library, source, _typ eProvider); 10187 ResolverVisitor visitor = new ResolverVisitor.con1(library, source, _typ eProvider);
10128 ast.accept(visitor); 10188 ast.accept(visitor);
10129 for (ProxyConditionalAnalysisError conditionalCode in visitor.proxyCondi tionalAnalysisErrors) {
10130 if (conditionalCode.shouldIncludeErrorCode()) {
10131 visitor.reportError(conditionalCode.analysisError);
10132 }
10133 }
10134 } 10189 }
10135 } finally { 10190 } finally {
10136 timeCounter.stop(); 10191 timeCounter.stop();
10137 } 10192 }
10138 // Angular 10193 // Angular
10139 timeCounter = PerformanceStatistics.angular.start(); 10194 timeCounter = PerformanceStatistics.angular.start();
10140 try { 10195 try {
10141 for (Source source in library.compilationUnitSources) { 10196 for (Source source in library.compilationUnitSources) {
10142 CompilationUnit ast = library.getAST(source); 10197 CompilationUnit ast = library.getAST(source);
10143 new AngularCompilationUnitBuilder(_errorListener, source, ast).build(); 10198 new AngularCompilationUnitBuilder(_errorListener, source, ast).build();
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
10560 */ 10615 */
10561 void _resolveReferencesAndTypesInLibrary(ResolvableLibrary library) { 10616 void _resolveReferencesAndTypesInLibrary(ResolvableLibrary library) {
10562 TimeCounter_TimeCounterHandle timeCounter = PerformanceStatistics.resolve.st art(); 10617 TimeCounter_TimeCounterHandle timeCounter = PerformanceStatistics.resolve.st art();
10563 try { 10618 try {
10564 for (ResolvableCompilationUnit unit in library.resolvableCompilationUnits) { 10619 for (ResolvableCompilationUnit unit in library.resolvableCompilationUnits) {
10565 Source source = unit.source; 10620 Source source = unit.source;
10566 CompilationUnit ast = unit.compilationUnit; 10621 CompilationUnit ast = unit.compilationUnit;
10567 ast.accept(new VariableResolverVisitor.con3(library, source, _typeProvid er)); 10622 ast.accept(new VariableResolverVisitor.con3(library, source, _typeProvid er));
10568 ResolverVisitor visitor = new ResolverVisitor.con4(library, source, _typ eProvider); 10623 ResolverVisitor visitor = new ResolverVisitor.con4(library, source, _typ eProvider);
10569 ast.accept(visitor); 10624 ast.accept(visitor);
10570 for (ProxyConditionalAnalysisError conditionalCode in visitor.proxyCondi tionalAnalysisErrors) {
10571 if (conditionalCode.shouldIncludeErrorCode()) {
10572 visitor.reportError(conditionalCode.analysisError);
10573 }
10574 }
10575 } 10625 }
10576 } finally { 10626 } finally {
10577 timeCounter.stop(); 10627 timeCounter.stop();
10578 } 10628 }
10579 // Angular 10629 // Angular
10580 timeCounter = PerformanceStatistics.angular.start(); 10630 timeCounter = PerformanceStatistics.angular.start();
10581 try { 10631 try {
10582 for (ResolvableCompilationUnit unit in library.resolvableCompilationUnits) { 10632 for (ResolvableCompilationUnit unit in library.resolvableCompilationUnits) {
10583 Source source = unit.source; 10633 Source source = unit.source;
10584 CompilationUnit ast = unit.compilationUnit; 10634 CompilationUnit ast = unit.compilationUnit;
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
10757 /** 10807 /**
10758 * Initializes [keys] and [values]. 10808 * Initializes [keys] and [values].
10759 */ 10809 */
10760 void _initArrays(int initialCapacity) { 10810 void _initArrays(int initialCapacity) {
10761 _keys = new List<String>(initialCapacity); 10811 _keys = new List<String>(initialCapacity);
10762 _values = new List<ExecutableElement>(initialCapacity); 10812 _values = new List<ExecutableElement>(initialCapacity);
10763 } 10813 }
10764 } 10814 }
10765 10815
10766 /** 10816 /**
10767 * This class is a wrapper for an [AnalysisError] which can also be queried afte r resolution
10768 * to find out if the error should actually be reported. In this case, these err ors are conditional
10769 * on the non-existence of an `@proxy` annotation.
10770 *
10771 * If we have other conditional error codes in the future, we should have this c lass implement some
10772 * ConditionalErrorCode so that after resolution, a list of ConditionalErrorCode can be visited
10773 * instead of multiple lists of *ConditionalErrorCodes.
10774 */
10775 class ProxyConditionalAnalysisError {
10776 /**
10777 * The enclosing [ClassElement], this is what will determine if the error code should, or
10778 * should not, be generated on the source.
10779 */
10780 final Element _enclosingElement;
10781
10782 /**
10783 * The conditional analysis error.
10784 */
10785 final AnalysisError analysisError;
10786
10787 /**
10788 * Instantiate a new [ProxyConditionalAnalysisError] with some enclosing eleme nt and the
10789 * conditional analysis error.
10790 *
10791 * @param enclosingElement the enclosing element
10792 * @param analysisError the conditional analysis error
10793 */
10794 ProxyConditionalAnalysisError(this._enclosingElement, this.analysisError);
10795
10796 /**
10797 * Return `true` iff the enclosing class has the proxy annotation.
10798 *
10799 * @return `true` iff the enclosing class has the proxy annotation
10800 */
10801 bool shouldIncludeErrorCode() {
10802 if (_enclosingElement is ClassElement) {
10803 return !(_enclosingElement as ClassElement).isOrInheritsProxy;
10804 }
10805 return true;
10806 }
10807 }
10808
10809 /**
10810 * Instances of the class `Library` represent the data about a single library du ring the 10817 * Instances of the class `Library` represent the data about a single library du ring the
10811 * resolution of some (possibly different) library. They are not intended to be used except during 10818 * resolution of some (possibly different) library. They are not intended to be used except during
10812 * the resolution process. 10819 * the resolution process.
10813 */ 10820 */
10814 class ResolvableLibrary { 10821 class ResolvableLibrary {
10815 /** 10822 /**
10816 * The source specifying the defining compilation unit of this library. 10823 * The source specifying the defining compilation unit of this library.
10817 */ 10824 */
10818 final Source librarySource; 10825 final Source librarySource;
10819 10826
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
11112 * The object keeping track of which elements have had their types overridden. 11119 * The object keeping track of which elements have had their types overridden.
11113 */ 11120 */
11114 TypeOverrideManager _overrideManager = new TypeOverrideManager(); 11121 TypeOverrideManager _overrideManager = new TypeOverrideManager();
11115 11122
11116 /** 11123 /**
11117 * The object keeping track of which elements have had their types promoted. 11124 * The object keeping track of which elements have had their types promoted.
11118 */ 11125 */
11119 TypePromotionManager _promoteManager = new TypePromotionManager(); 11126 TypePromotionManager _promoteManager = new TypePromotionManager();
11120 11127
11121 /** 11128 /**
11122 * Proxy conditional error codes.
11123 */
11124 List<ProxyConditionalAnalysisError> _proxyConditionalAnalysisErrors = new List <ProxyConditionalAnalysisError>();
11125
11126 /**
11127 * Initialize a newly created visitor to resolve the nodes in a compilation un it. 11129 * Initialize a newly created visitor to resolve the nodes in a compilation un it.
11128 * 11130 *
11129 * @param library the library containing the compilation unit being resolved 11131 * @param library the library containing the compilation unit being resolved
11130 * @param source the source representing the compilation unit being visited 11132 * @param source the source representing the compilation unit being visited
11131 * @param typeProvider the object used to access the types from the core libra ry 11133 * @param typeProvider the object used to access the types from the core libra ry
11132 */ 11134 */
11133 ResolverVisitor.con1(Library library, Source source, TypeProvider typeProvider ) : super.con1(library, source, typeProvider) { 11135 ResolverVisitor.con1(Library library, Source source, TypeProvider typeProvider ) : super.con1(library, source, typeProvider) {
11134 this._inheritanceManager = library.inheritanceManager; 11136 this._inheritanceManager = library.inheritanceManager;
11135 this._elementResolver = new ElementResolver(this); 11137 this._elementResolver = new ElementResolver(this);
11136 this._typeAnalyzer = new StaticTypeAnalyzer(this); 11138 this._typeAnalyzer = new StaticTypeAnalyzer(this);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
11188 */ 11190 */
11189 TypeOverrideManager get overrideManager => _overrideManager; 11191 TypeOverrideManager get overrideManager => _overrideManager;
11190 11192
11191 /** 11193 /**
11192 * Return the object keeping track of which elements have had their types prom oted. 11194 * Return the object keeping track of which elements have had their types prom oted.
11193 * 11195 *
11194 * @return the object keeping track of which elements have had their types pro moted 11196 * @return the object keeping track of which elements have had their types pro moted
11195 */ 11197 */
11196 TypePromotionManager get promoteManager => _promoteManager; 11198 TypePromotionManager get promoteManager => _promoteManager;
11197 11199
11198 List<ProxyConditionalAnalysisError> get proxyConditionalAnalysisErrors => _pro xyConditionalAnalysisErrors;
11199
11200 @override 11200 @override
11201 Object visitAsExpression(AsExpression node) { 11201 Object visitAsExpression(AsExpression node) {
11202 super.visitAsExpression(node); 11202 super.visitAsExpression(node);
11203 overrideExpression(node.expression, node.type.type); 11203 overrideExpression(node.expression, node.type.type);
11204 return null; 11204 return null;
11205 } 11205 }
11206 11206
11207 @override 11207 @override
11208 Object visitAssertStatement(AssertStatement node) { 11208 Object visitAssertStatement(AssertStatement node) {
11209 super.visitAssertStatement(node); 11209 super.visitAssertStatement(node);
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
11878 if (!variable.isConst && !variable.isFinal) { 11878 if (!variable.isConst && !variable.isFinal) {
11879 return; 11879 return;
11880 } 11880 }
11881 } 11881 }
11882 DartType currentType = _getBestType(element); 11882 DartType currentType = _getBestType(element);
11883 if (currentType == null || !currentType.isMoreSpecificThan(potentialType)) { 11883 if (currentType == null || !currentType.isMoreSpecificThan(potentialType)) {
11884 _overrideManager.setType(element, potentialType); 11884 _overrideManager.setType(element, potentialType);
11885 } 11885 }
11886 } 11886 }
11887 11887
11888 /**
11889 * Report a conditional analysis error with the given error code and arguments .
11890 *
11891 * @param enclosingElement the enclosing element
11892 * @param errorCode the error code of the error to be reported
11893 * @param node the node specifying the location of the error
11894 * @param arguments the arguments to the error, used to compose the error mess age
11895 */
11896 void reportProxyConditionalErrorForNode(Element enclosingElement, ErrorCode er rorCode, AstNode node, List<Object> arguments) {
11897 _proxyConditionalAnalysisErrors.add(new ProxyConditionalAnalysisError(enclos ingElement, new AnalysisError.con2(source, node.offset, node.length, errorCode, arguments)));
11898 }
11899
11900 /**
11901 * Report a conditional analysis error with the given error code and arguments .
11902 *
11903 * @param enclosingElement the enclosing element
11904 * @param errorCode the error code of the error to be reported
11905 * @param offset the offset of the location of the error
11906 * @param length the length of the location of the error
11907 * @param arguments the arguments to the error, used to compose the error mess age
11908 */
11909 void reportProxyConditionalErrorForOffset(Element enclosingElement, ErrorCode errorCode, int offset, int length, List<Object> arguments) {
11910 _proxyConditionalAnalysisErrors.add(new ProxyConditionalAnalysisError(enclos ingElement, new AnalysisError.con2(source, offset, length, errorCode, arguments) ));
11911 }
11912
11913 /**
11914 * Report a conditional analysis error with the given error code and arguments .
11915 *
11916 * @param enclosingElement the enclosing element
11917 * @param errorCode the error code of the error to be reported
11918 * @param token the token specifying the location of the error
11919 * @param arguments the arguments to the error, used to compose the error mess age
11920 */
11921 void reportProxyConditionalErrorForToken(Element enclosingElement, ErrorCode e rrorCode, sc.Token token, List<Object> arguments) {
11922 _proxyConditionalAnalysisErrors.add(new ProxyConditionalAnalysisError(enclos ingElement, new AnalysisError.con2(source, token.offset, token.length, errorCode , arguments)));
11923 }
11924
11925 @override 11888 @override
11926 void visitForEachStatementInScope(ForEachStatement node) { 11889 void visitForEachStatementInScope(ForEachStatement node) {
11927 // 11890 //
11928 // We visit the iterator before the loop variable because the loop variable cannot be in scope 11891 // We visit the iterator before the loop variable because the loop variable cannot be in scope
11929 // while visiting the iterator. 11892 // while visiting the iterator.
11930 // 11893 //
11931 Expression iterator = node.iterator; 11894 Expression iterator = node.iterator;
11932 safelyVisit(iterator); 11895 safelyVisit(iterator);
11933 DeclaredIdentifier loopVariable = node.loopVariable; 11896 DeclaredIdentifier loopVariable = node.loopVariable;
11934 SimpleIdentifier identifier = node.identifier; 11897 SimpleIdentifier identifier = node.identifier;
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
12512 * Pushes a new [Scope] into the visitor. 12475 * Pushes a new [Scope] into the visitor.
12513 * 12476 *
12514 * @return the new [Scope]. 12477 * @return the new [Scope].
12515 */ 12478 */
12516 Scope pushNameScope() { 12479 Scope pushNameScope() {
12517 Scope newScope = new EnclosedScope(_nameScope); 12480 Scope newScope = new EnclosedScope(_nameScope);
12518 _nameScope = newScope; 12481 _nameScope = newScope;
12519 return _nameScope; 12482 return _nameScope;
12520 } 12483 }
12521 12484
12522 /**
12523 * Report an error with the given analysis error.
12524 *
12525 * @param errorCode analysis error
12526 */
12527 void reportError(AnalysisError analysisError) {
12528 _errorListener.onError(analysisError);
12529 }
12530
12531 @override 12485 @override
12532 Object visitBlock(Block node) { 12486 Object visitBlock(Block node) {
12533 Scope outerScope = _nameScope; 12487 Scope outerScope = _nameScope;
12534 try { 12488 try {
12535 EnclosedScope enclosedScope = new EnclosedScope(_nameScope); 12489 EnclosedScope enclosedScope = new EnclosedScope(_nameScope);
12536 _hideNamesDefinedInBlock(enclosedScope, node); 12490 _hideNamesDefinedInBlock(enclosedScope, node);
12537 _nameScope = enclosedScope; 12491 _nameScope = enclosedScope;
12538 super.visitBlock(node); 12492 super.visitBlock(node);
12539 } finally { 12493 } finally {
12540 _nameScope = outerScope; 12494 _nameScope = outerScope;
(...skipping 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after
13585 NodeList<TypeName> arguments = typeArguments.arguments; 13539 NodeList<TypeName> arguments = typeArguments.arguments;
13586 if (arguments != null && arguments.length == 1) { 13540 if (arguments != null && arguments.length == 1) {
13587 TypeName argumentTypeName = arguments[0]; 13541 TypeName argumentTypeName = arguments[0];
13588 DartType argumentType = _getType(argumentTypeName); 13542 DartType argumentType = _getType(argumentTypeName);
13589 if (argumentType != null) { 13543 if (argumentType != null) {
13590 staticType = argumentType; 13544 staticType = argumentType;
13591 } 13545 }
13592 } 13546 }
13593 } 13547 }
13594 _recordStaticType(node, _typeProvider.listType.substitute4(<DartType> [stati cType])); 13548 _recordStaticType(node, _typeProvider.listType.substitute4(<DartType> [stati cType]));
13595 NodeList<Expression> elements = node.elements;
13596 int count = elements.length;
13597 if (count > 0) {
13598 DartType propagatedType = elements[0].bestType;
13599 for (int i = 1; i < count; i++) {
13600 DartType elementType = elements[i].bestType;
13601 if (propagatedType != elementType) {
13602 propagatedType = _dynamicType;
13603 } else {
13604 propagatedType = propagatedType.getLeastUpperBound(elementType);
13605 if (propagatedType == null) {
13606 propagatedType = _dynamicType;
13607 }
13608 }
13609 }
13610 if (propagatedType.isMoreSpecificThan(staticType)) {
13611 _recordPropagatedType(node, _typeProvider.listType.substitute4(<DartType > [propagatedType]));
13612 }
13613 }
13614 return null; 13549 return null;
13615 } 13550 }
13616 13551
13617 /** 13552 /**
13618 * The Dart Language Specification, 12.7: <blockquote>The static type of a map literal of the form 13553 * The Dart Language Specification, 12.7: <blockquote>The static type of a map literal of the form
13619 * <i><b>const</b> &lt;String, V&gt; {k<sub>1</sub>:e<sub>1</sub>, &hellip;, 13554 * <i><b>const</b> &lt;K, V&gt; {k<sub>1</sub>:e<sub>1</sub>, &hellip;,
13620 * k<sub>n</sub>:e<sub>n</sub>}</i> or the form <i>&lt;String, V&gt; {k<sub>1< /sub>:e<sub>1</sub>, 13555 * k<sub>n</sub>:e<sub>n</sub>}</i> or the form <i>&lt;K, V&gt; {k<sub>1</sub> :e<sub>1</sub>,
13621 * &hellip;, k<sub>n</sub>:e<sub>n</sub>}</i> is `Map&lt;String, V&gt;`. The s tatic type a 13556 * &hellip;, k<sub>n</sub>:e<sub>n</sub>}</i> is `Map&lt;K, V&gt;`. The static type a map
13622 * map literal of the form <i><b>const</b> {k<sub>1</sub>:e<sub>1</sub>, &hell ip;, 13557 * literal of the form <i><b>const</b> {k<sub>1</sub>:e<sub>1</sub>, &hellip;,
13623 * k<sub>n</sub>:e<sub>n</sub>}</i> or the form <i>{k<sub>1</sub>:e<sub>1</sub >, &hellip;, 13558 * k<sub>n</sub>:e<sub>n</sub>}</i> or the form <i>{k<sub>1</sub>:e<sub>1</sub >, &hellip;,
13624 * k<sub>n</sub>:e<sub>n</sub>}</i> is `Map&lt;String, dynamic&gt;`. 13559 * k<sub>n</sub>:e<sub>n</sub>}</i> is `Map&lt;dynamic, dynamic&gt;`.
13625 * 13560 *
13626 * It is a compile-time error if the first type argument to a map literal is n ot 13561 * It is a compile-time error if the first type argument to a map literal is n ot
13627 * <i>String</i>.</blockquote> 13562 * <i>String</i>.</blockquote>
13628 */ 13563 */
13629 @override 13564 @override
13630 Object visitMapLiteral(MapLiteral node) { 13565 Object visitMapLiteral(MapLiteral node) {
13631 DartType staticKeyType = _dynamicType; 13566 DartType staticKeyType = _dynamicType;
13632 DartType staticValueType = _dynamicType; 13567 DartType staticValueType = _dynamicType;
13633 TypeArgumentList typeArguments = node.typeArguments; 13568 TypeArgumentList typeArguments = node.typeArguments;
13634 if (typeArguments != null) { 13569 if (typeArguments != null) {
13635 NodeList<TypeName> arguments = typeArguments.arguments; 13570 NodeList<TypeName> arguments = typeArguments.arguments;
13636 if (arguments != null && arguments.length == 2) { 13571 if (arguments != null && arguments.length == 2) {
13637 TypeName entryKeyTypeName = arguments[0]; 13572 TypeName entryKeyTypeName = arguments[0];
13638 DartType entryKeyType = _getType(entryKeyTypeName); 13573 DartType entryKeyType = _getType(entryKeyTypeName);
13639 if (entryKeyType != null) { 13574 if (entryKeyType != null) {
13640 staticKeyType = entryKeyType; 13575 staticKeyType = entryKeyType;
13641 } 13576 }
13642 TypeName entryValueTypeName = arguments[1]; 13577 TypeName entryValueTypeName = arguments[1];
13643 DartType entryValueType = _getType(entryValueTypeName); 13578 DartType entryValueType = _getType(entryValueTypeName);
13644 if (entryValueType != null) { 13579 if (entryValueType != null) {
13645 staticValueType = entryValueType; 13580 staticValueType = entryValueType;
13646 } 13581 }
13647 } 13582 }
13648 } 13583 }
13649 _recordStaticType(node, _typeProvider.mapType.substitute4(<DartType> [static KeyType, staticValueType])); 13584 _recordStaticType(node, _typeProvider.mapType.substitute4(<DartType> [static KeyType, staticValueType]));
13650 NodeList<MapLiteralEntry> entries = node.entries;
13651 int count = entries.length;
13652 if (count > 0) {
13653 MapLiteralEntry entry = entries[0];
13654 DartType propagatedKeyType = entry.key.bestType;
13655 DartType propagatedValueType = entry.value.bestType;
13656 for (int i = 1; i < count; i++) {
13657 entry = entries[i];
13658 DartType elementKeyType = entry.key.bestType;
13659 if (propagatedKeyType != elementKeyType) {
13660 propagatedKeyType = _dynamicType;
13661 } else {
13662 propagatedKeyType = propagatedKeyType.getLeastUpperBound(elementKeyTyp e);
13663 if (propagatedKeyType == null) {
13664 propagatedKeyType = _dynamicType;
13665 }
13666 }
13667 DartType elementValueType = entry.value.bestType;
13668 if (propagatedValueType != elementValueType) {
13669 propagatedValueType = _dynamicType;
13670 } else {
13671 propagatedValueType = propagatedValueType.getLeastUpperBound(elementVa lueType);
13672 if (propagatedValueType == null) {
13673 propagatedValueType = _dynamicType;
13674 }
13675 }
13676 }
13677 bool betterKey = propagatedKeyType != null && propagatedKeyType.isMoreSpec ificThan(staticKeyType);
13678 bool betterValue = propagatedValueType != null && propagatedValueType.isMo reSpecificThan(staticValueType);
13679 if (betterKey || betterValue) {
13680 if (!betterKey) {
13681 propagatedKeyType = staticKeyType;
13682 }
13683 if (!betterValue) {
13684 propagatedValueType = staticValueType;
13685 }
13686 _recordPropagatedType(node, _typeProvider.mapType.substitute4(<DartType> [propagatedKeyType, propagatedValueType]));
13687 }
13688 }
13689 return null; 13585 return null;
13690 } 13586 }
13691 13587
13692 /** 13588 /**
13693 * The Dart Language Specification, 12.15.1: <blockquote>An ordinary method in vocation <i>i</i> 13589 * The Dart Language Specification, 12.15.1: <blockquote>An ordinary method in vocation <i>i</i>
13694 * has the form <i>o.m(a<sub>1</sub>, &hellip;, a<sub>n</sub>, x<sub>n+1</sub> : a<sub>n+1</sub>, 13590 * has the form <i>o.m(a<sub>1</sub>, &hellip;, a<sub>n</sub>, x<sub>n+1</sub> : a<sub>n+1</sub>,
13695 * &hellip;, x<sub>n+k</sub>: a<sub>n+k</sub>)</i>. 13591 * &hellip;, x<sub>n+k</sub>: a<sub>n+k</sub>)</i>.
13696 * 13592 *
13697 * Let <i>T</i> be the static type of <i>o</i>. It is a static type warning if <i>T</i> does not 13593 * Let <i>T</i> be the static type of <i>o</i>. It is a static type warning if <i>T</i> does not
13698 * have an accessible instance member named <i>m</i>. If <i>T.m</i> exists, it is a static warning 13594 * have an accessible instance member named <i>m</i>. If <i>T.m</i> exists, it is a static warning
(...skipping 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after
14987 * @param outerScope the outer scope in which types might be overridden 14883 * @param outerScope the outer scope in which types might be overridden
14988 */ 14884 */
14989 TypeOverrideManager_TypeOverrideScope(this._outerScope); 14885 TypeOverrideManager_TypeOverrideScope(this._outerScope);
14990 14886
14991 /** 14887 /**
14992 * Apply a set of overrides that were previously captured. 14888 * Apply a set of overrides that were previously captured.
14993 * 14889 *
14994 * @param overrides the overrides to be applied 14890 * @param overrides the overrides to be applied
14995 */ 14891 */
14996 void applyOverrides(Map<Element, DartType> overrides) { 14892 void applyOverrides(Map<Element, DartType> overrides) {
14997 for (MapIterator<Element, DartType> iter = SingleMapIterator.forMap(override s); iter.moveNext();) { 14893 for (MapEntry<Element, DartType> entry in getMapEntrySet(overrides)) {
14998 _overridenTypes[iter.key] = iter.value; 14894 _overridenTypes[entry.getKey()] = entry.getValue();
14999 } 14895 }
15000 } 14896 }
15001 14897
15002 /** 14898 /**
15003 * Return a table mapping the elements whose type is overridden in the current scope to the 14899 * Return a table mapping the elements whose type is overridden in the current scope to the
15004 * overriding type. 14900 * overriding type.
15005 * 14901 *
15006 * @return the overrides in the current scope 14902 * @return the overrides in the current scope
15007 */ 14903 */
15008 Map<Element, DartType> captureLocalOverrides() => _overridenTypes; 14904 Map<Element, DartType> captureLocalOverrides() => _overridenTypes;
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
15581 * 15477 *
15582 * @param library the library containing the compilation unit being resolved 15478 * @param library the library containing the compilation unit being resolved
15583 * @param source the source representing the compilation unit being visited 15479 * @param source the source representing the compilation unit being visited
15584 * @param typeProvider the object used to access the types from the core libra ry 15480 * @param typeProvider the object used to access the types from the core libra ry
15585 */ 15481 */
15586 TypeResolverVisitor.con4(ResolvableLibrary library, Source source, TypeProvide r typeProvider) : super.con4(library, source, typeProvider) { 15482 TypeResolverVisitor.con4(ResolvableLibrary library, Source source, TypeProvide r typeProvider) : super.con4(library, source, typeProvider) {
15587 _dynamicType = typeProvider.dynamicType; 15483 _dynamicType = typeProvider.dynamicType;
15588 } 15484 }
15589 15485
15590 @override 15486 @override
15487 Object visitAnnotation(Annotation node) {
15488 //
15489 // Visit annotations, if the annotation is @proxy, on a class, and "proxy" r esolves to the proxy
15490 // annotation in dart.core, then create create the ElementAnnotationImpl and set it as the
15491 // metadata on the enclosing class.
15492 //
15493 // Element resolution is done in the ElementResolver, and this work will be done in the general
15494 // case for all annotations in the ElementResolver. The reason we resolve th is particular
15495 // element early is so that ClassElement.isProxy() returns the correct infor mation during all
15496 // phases of the ElementResolver.
15497 //
15498 super.visitAnnotation(node);
15499 Identifier identifier = node.name;
15500 if (identifier.name.endsWith(ElementAnnotationImpl.PROXY_VARIABLE_NAME) && n ode.parent is ClassDeclaration) {
15501 Element element = nameScope.lookup(identifier, definingLibrary);
15502 if (element != null && element.library.isDartCore && element is PropertyAc cessorElement) {
15503 // This is the @proxy from dart.core
15504 ClassDeclaration classDeclaration = node.parent as ClassDeclaration;
15505 ElementAnnotationImpl elementAnnotation = new ElementAnnotationImpl(elem ent);
15506 node.elementAnnotation = elementAnnotation;
15507 (classDeclaration.element as ClassElementImpl).metadata = <ElementAnnota tionImpl> [elementAnnotation];
15508 }
15509 }
15510 return null;
15511 }
15512
15513 @override
15591 Object visitCatchClause(CatchClause node) { 15514 Object visitCatchClause(CatchClause node) {
15592 super.visitCatchClause(node); 15515 super.visitCatchClause(node);
15593 SimpleIdentifier exception = node.exceptionParameter; 15516 SimpleIdentifier exception = node.exceptionParameter;
15594 if (exception != null) { 15517 if (exception != null) {
15595 // If an 'on' clause is provided the type of the exception parameter is th e type in the 'on' 15518 // If an 'on' clause is provided the type of the exception parameter is th e type in the 'on'
15596 // clause. Otherwise, the type of the exception parameter is 'Object'. 15519 // clause. Otherwise, the type of the exception parameter is 'Object'.
15597 TypeName exceptionTypeName = node.exceptionType; 15520 TypeName exceptionTypeName = node.exceptionType;
15598 DartType exceptionType; 15521 DartType exceptionType;
15599 if (exceptionTypeName == null) { 15522 if (exceptionTypeName == null) {
15600 exceptionType = typeProvider.dynamicType; 15523 exceptionType = typeProvider.dynamicType;
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
15915 reportErrorForNode(CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE, typ eName, [typeName.name]); 15838 reportErrorForNode(CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE, typ eName, [typeName.name]);
15916 } else if (typeNameSimple.name == "boolean") { 15839 } else if (typeNameSimple.name == "boolean") {
15917 reportErrorForNode(StaticWarningCode.UNDEFINED_CLASS_BOOLEAN, typeNameSi mple, []); 15840 reportErrorForNode(StaticWarningCode.UNDEFINED_CLASS_BOOLEAN, typeNameSi mple, []);
15918 } else if (_isTypeNameInCatchClause(node)) { 15841 } else if (_isTypeNameInCatchClause(node)) {
15919 reportErrorForNode(StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE, typeName, [typeName.name]); 15842 reportErrorForNode(StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE, typeName, [typeName.name]);
15920 } else if (_isTypeNameInAsExpression(node)) { 15843 } else if (_isTypeNameInAsExpression(node)) {
15921 reportErrorForNode(StaticWarningCode.CAST_TO_NON_TYPE, typeName, [typeNa me.name]); 15844 reportErrorForNode(StaticWarningCode.CAST_TO_NON_TYPE, typeName, [typeNa me.name]);
15922 } else if (_isTypeNameInIsExpression(node)) { 15845 } else if (_isTypeNameInIsExpression(node)) {
15923 reportErrorForNode(StaticWarningCode.TYPE_TEST_NON_TYPE, typeName, [type Name.name]); 15846 reportErrorForNode(StaticWarningCode.TYPE_TEST_NON_TYPE, typeName, [type Name.name]);
15924 } else if ((redirectingConstructorKind = _getRedirectingConstructorKind(no de)) != null) { 15847 } else if ((redirectingConstructorKind = _getRedirectingConstructorKind(no de)) != null) {
15925 ErrorCode errorCode = (redirectingConstructorKind == RedirectingConstruc torKind.CONST ? CompileTimeErrorCode.REDIRECT_TO_NON_CLASS : StaticWarningCode.R EDIRECT_TO_NON_CLASS) as ErrorCode; 15848 ErrorCode errorCode = (redirectingConstructorKind == RedirectingConstruc torKind.CONST ? CompileTimeErrorCode.REDIRECT_TO_NON_CLASS : StaticWarningCode.R EDIRECT_TO_NON_CLASS);
15926 reportErrorForNode(errorCode, typeName, [typeName.name]); 15849 reportErrorForNode(errorCode, typeName, [typeName.name]);
15927 } else if (_isTypeNameInTypeArgumentList(node)) { 15850 } else if (_isTypeNameInTypeArgumentList(node)) {
15928 reportErrorForNode(StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT, type Name, [typeName.name]); 15851 reportErrorForNode(StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT, type Name, [typeName.name]);
15929 } else { 15852 } else {
15930 reportErrorForNode(StaticWarningCode.UNDEFINED_CLASS, typeName, [typeNam e.name]); 15853 reportErrorForNode(StaticWarningCode.UNDEFINED_CLASS, typeName, [typeNam e.name]);
15931 } 15854 }
15932 elementValid = false; 15855 elementValid = false;
15933 } 15856 }
15934 if (!elementValid) { 15857 if (!elementValid) {
15935 if (element is MultiplyDefinedElement) { 15858 if (element is MultiplyDefinedElement) {
(...skipping 26 matching lines...) Expand all
15962 } else { 15885 } else {
15963 // The name does not represent a type. 15886 // The name does not represent a type.
15964 RedirectingConstructorKind redirectingConstructorKind; 15887 RedirectingConstructorKind redirectingConstructorKind;
15965 if (_isTypeNameInCatchClause(node)) { 15888 if (_isTypeNameInCatchClause(node)) {
15966 reportErrorForNode(StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE, typeName, [typeName.name]); 15889 reportErrorForNode(StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE, typeName, [typeName.name]);
15967 } else if (_isTypeNameInAsExpression(node)) { 15890 } else if (_isTypeNameInAsExpression(node)) {
15968 reportErrorForNode(StaticWarningCode.CAST_TO_NON_TYPE, typeName, [typeNa me.name]); 15891 reportErrorForNode(StaticWarningCode.CAST_TO_NON_TYPE, typeName, [typeNa me.name]);
15969 } else if (_isTypeNameInIsExpression(node)) { 15892 } else if (_isTypeNameInIsExpression(node)) {
15970 reportErrorForNode(StaticWarningCode.TYPE_TEST_NON_TYPE, typeName, [type Name.name]); 15893 reportErrorForNode(StaticWarningCode.TYPE_TEST_NON_TYPE, typeName, [type Name.name]);
15971 } else if ((redirectingConstructorKind = _getRedirectingConstructorKind(no de)) != null) { 15894 } else if ((redirectingConstructorKind = _getRedirectingConstructorKind(no de)) != null) {
15972 ErrorCode errorCode = (redirectingConstructorKind == RedirectingConstruc torKind.CONST ? CompileTimeErrorCode.REDIRECT_TO_NON_CLASS : StaticWarningCode.R EDIRECT_TO_NON_CLASS) as ErrorCode; 15895 ErrorCode errorCode = (redirectingConstructorKind == RedirectingConstruc torKind.CONST ? CompileTimeErrorCode.REDIRECT_TO_NON_CLASS : StaticWarningCode.R EDIRECT_TO_NON_CLASS);
15973 reportErrorForNode(errorCode, typeName, [typeName.name]); 15896 reportErrorForNode(errorCode, typeName, [typeName.name]);
15974 } else if (_isTypeNameInTypeArgumentList(node)) { 15897 } else if (_isTypeNameInTypeArgumentList(node)) {
15975 reportErrorForNode(StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT, type Name, [typeName.name]); 15898 reportErrorForNode(StaticTypeWarningCode.NON_TYPE_AS_TYPE_ARGUMENT, type Name, [typeName.name]);
15976 } else { 15899 } else {
15977 AstNode parent = typeName.parent; 15900 AstNode parent = typeName.parent;
15978 while (parent is TypeName) { 15901 while (parent is TypeName) {
15979 parent = parent.parent; 15902 parent = parent.parent;
15980 } 15903 }
15981 if (parent is ExtendsClause || parent is ImplementsClause || parent is W ithClause || parent is ClassTypeAlias) { 15904 if (parent is ExtendsClause || parent is ImplementsClause || parent is W ithClause || parent is ClassTypeAlias) {
15982 } else { 15905 } else {
(...skipping 1355 matching lines...) Expand 10 before | Expand all | Expand 10 after
17338 return new Namespace(definedNames); 17261 return new Namespace(definedNames);
17339 } 17262 }
17340 17263
17341 /** 17264 /**
17342 * Add all of the names in the given namespace to the given mapping table. 17265 * Add all of the names in the given namespace to the given mapping table.
17343 * 17266 *
17344 * @param definedNames the mapping table to which the names in the given names pace are to be added 17267 * @param definedNames the mapping table to which the names in the given names pace are to be added
17345 * @param namespace the namespace containing the names to be added to this nam espace 17268 * @param namespace the namespace containing the names to be added to this nam espace
17346 */ 17269 */
17347 void _addAllFromMap(Map<String, Element> definedNames, Map<String, Element> ne wNames) { 17270 void _addAllFromMap(Map<String, Element> definedNames, Map<String, Element> ne wNames) {
17348 for (MapIterator<String, Element> iter = SingleMapIterator.forMap(newNames); iter.moveNext();) { 17271 for (MapEntry<String, Element> entry in getMapEntrySet(newNames)) {
17349 definedNames[iter.key] = iter.value; 17272 definedNames[entry.getKey()] = entry.getValue();
17350 } 17273 }
17351 } 17274 }
17352 17275
17353 /** 17276 /**
17354 * Add all of the names in the given namespace to the given mapping table. 17277 * Add all of the names in the given namespace to the given mapping table.
17355 * 17278 *
17356 * @param definedNames the mapping table to which the names in the given names pace are to be added 17279 * @param definedNames the mapping table to which the names in the given names pace are to be added
17357 * @param namespace the namespace containing the names to be added to this nam espace 17280 * @param namespace the namespace containing the names to be added to this nam espace
17358 */ 17281 */
17359 void _addAllFromNamespace(Map<String, Element> definedNames, Namespace namespa ce) { 17282 void _addAllFromNamespace(Map<String, Element> definedNames, Namespace namespa ce) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
17421 /** 17344 /**
17422 * Apply the given prefix to all of the names in the table of defined names. 17345 * Apply the given prefix to all of the names in the table of defined names.
17423 * 17346 *
17424 * @param definedNames the names that were defined before this operation 17347 * @param definedNames the names that were defined before this operation
17425 * @param prefixElement the element defining the prefix to be added to the nam es 17348 * @param prefixElement the element defining the prefix to be added to the nam es
17426 */ 17349 */
17427 Map<String, Element> _applyPrefix(Map<String, Element> definedNames, PrefixEle ment prefixElement) { 17350 Map<String, Element> _applyPrefix(Map<String, Element> definedNames, PrefixEle ment prefixElement) {
17428 if (prefixElement != null) { 17351 if (prefixElement != null) {
17429 String prefix = prefixElement.name; 17352 String prefix = prefixElement.name;
17430 Map<String, Element> newNames = new Map<String, Element>(); 17353 Map<String, Element> newNames = new Map<String, Element>();
17431 for (MapIterator<String, Element> iter = SingleMapIterator.forMap(definedN ames); iter.moveNext();) { 17354 for (MapEntry<String, Element> entry in getMapEntrySet(definedNames)) {
17432 newNames["${prefix}.${iter.key}"] = iter.value; 17355 newNames["${prefix}.${entry.getKey()}"] = entry.getValue();
17433 } 17356 }
17434 return newNames; 17357 return newNames;
17435 } else { 17358 } else {
17436 return definedNames; 17359 return definedNames;
17437 } 17360 }
17438 } 17361 }
17439 17362
17440 /** 17363 /**
17441 * Create a mapping table representing the export namespace of the given libra ry. 17364 * Create a mapping table representing the export namespace of the given libra ry.
17442 * 17365 *
(...skipping 1769 matching lines...) Expand 10 before | Expand all | Expand 10 after
19212 _errorReporter.reportErrorForNode(CompileTimeErrorCode.FIELD_INITIAL IZED_IN_PARAMETER_AND_INITIALIZER, fieldName, []); 19135 _errorReporter.reportErrorForNode(CompileTimeErrorCode.FIELD_INITIAL IZED_IN_PARAMETER_AND_INITIALIZER, fieldName, []);
19213 foundError = true; 19136 foundError = true;
19214 } else if (state == INIT_STATE.INIT_IN_INITIALIZERS) { 19137 } else if (state == INIT_STATE.INIT_IN_INITIALIZERS) {
19215 _errorReporter.reportErrorForNode(CompileTimeErrorCode.FIELD_INITIAL IZED_BY_MULTIPLE_INITIALIZERS, fieldName, [fieldElement.displayName]); 19138 _errorReporter.reportErrorForNode(CompileTimeErrorCode.FIELD_INITIAL IZED_BY_MULTIPLE_INITIALIZERS, fieldName, [fieldElement.displayName]);
19216 foundError = true; 19139 foundError = true;
19217 } 19140 }
19218 } 19141 }
19219 } 19142 }
19220 } 19143 }
19221 // Visit all of the states in the map to ensure that none were never initial ized. 19144 // Visit all of the states in the map to ensure that none were never initial ized.
19222 for (MapIterator<FieldElement, INIT_STATE> iter = SingleMapIterator.forMap(f ieldElementsMap); iter.moveNext();) { 19145 for (MapEntry<FieldElement, INIT_STATE> entry in getMapEntrySet(fieldElement sMap)) {
19223 if (iter.value == INIT_STATE.NOT_INIT) { 19146 if (entry.getValue() == INIT_STATE.NOT_INIT) {
19224 FieldElement fieldElement = iter.key; 19147 FieldElement fieldElement = entry.getKey();
19225 if (fieldElement.isConst) { 19148 if (fieldElement.isConst) {
19226 _errorReporter.reportErrorForNode(CompileTimeErrorCode.CONST_NOT_INITI ALIZED, node.returnType, [fieldElement.name]); 19149 _errorReporter.reportErrorForNode(CompileTimeErrorCode.CONST_NOT_INITI ALIZED, node.returnType, [fieldElement.name]);
19227 foundError = true; 19150 foundError = true;
19228 } else if (fieldElement.isFinal) { 19151 } else if (fieldElement.isFinal) {
19229 _errorReporter.reportErrorForNode(StaticWarningCode.FINAL_NOT_INITIALI ZED, node.returnType, [fieldElement.name]); 19152 _errorReporter.reportErrorForNode(StaticWarningCode.FINAL_NOT_INITIALI ZED, node.returnType, [fieldElement.name]);
19230 foundError = true; 19153 foundError = true;
19231 } 19154 }
19232 } 19155 }
19233 } 19156 }
19234 return foundError; 19157 return foundError;
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
19388 if (!overridingPositionalPT[i].isAssignableTo(overriddenPositionalPT[i])) { 19311 if (!overridingPositionalPT[i].isAssignableTo(overriddenPositionalPT[i])) {
19389 _errorReporter.reportErrorForNode(StaticWarningCode.INVALID_METHOD_OVERR IDE_OPTIONAL_PARAM_TYPE, parameterLocations[parameterIndex], [ 19312 _errorReporter.reportErrorForNode(StaticWarningCode.INVALID_METHOD_OVERR IDE_OPTIONAL_PARAM_TYPE, parameterLocations[parameterIndex], [
19390 overridingPositionalPT[i].displayName, 19313 overridingPositionalPT[i].displayName,
19391 overriddenPositionalPT[i].displayName, 19314 overriddenPositionalPT[i].displayName,
19392 overriddenExecutable.enclosingElement.displayName]); 19315 overriddenExecutable.enclosingElement.displayName]);
19393 return true; 19316 return true;
19394 } 19317 }
19395 parameterIndex++; 19318 parameterIndex++;
19396 } 19319 }
19397 // SWC.INVALID_METHOD_OVERRIDE_NAMED_PARAM_TYPE & SWC.INVALID_OVERRIDE_DIFFE RENT_DEFAULT_VALUES 19320 // SWC.INVALID_METHOD_OVERRIDE_NAMED_PARAM_TYPE & SWC.INVALID_OVERRIDE_DIFFE RENT_DEFAULT_VALUES
19398 MapIterator<String, DartType> overriddenNamedPTIterator = SingleMapIterator. forMap(overriddenNamedPT); 19321 JavaIterator<MapEntry<String, DartType>> overriddenNamedPTIterator = new Jav aIterator(getMapEntrySet(overriddenNamedPT));
19399 while (overriddenNamedPTIterator.moveNext()) { 19322 while (overriddenNamedPTIterator.hasNext) {
19400 DartType overridingType = overridingNamedPT[overriddenNamedPTIterator.key] ; 19323 MapEntry<String, DartType> overriddenNamedPTEntry = overriddenNamedPTItera tor.next();
19324 DartType overridingType = overridingNamedPT[overriddenNamedPTEntry.getKey( )];
19401 if (overridingType == null) { 19325 if (overridingType == null) {
19402 // Error, this is never reached- INVALID_OVERRIDE_NAMED would have been created above if 19326 // Error, this is never reached- INVALID_OVERRIDE_NAMED would have been created above if
19403 // this could be reached. 19327 // this could be reached.
19404 continue; 19328 continue;
19405 } 19329 }
19406 if (!overriddenNamedPTIterator.value.isAssignableTo(overridingType)) { 19330 if (!overriddenNamedPTEntry.getValue().isAssignableTo(overridingType)) {
19407 // lookup the parameter for the error to select 19331 // lookup the parameter for the error to select
19408 ParameterElement parameterToSelect = null; 19332 ParameterElement parameterToSelect = null;
19409 AstNode parameterLocationToSelect = null; 19333 AstNode parameterLocationToSelect = null;
19410 for (int i = 0; i < parameters.length; i++) { 19334 for (int i = 0; i < parameters.length; i++) {
19411 ParameterElement parameter = parameters[i]; 19335 ParameterElement parameter = parameters[i];
19412 if (parameter.parameterKind == ParameterKind.NAMED && overriddenNamedP TIterator.key == parameter.name) { 19336 if (parameter.parameterKind == ParameterKind.NAMED && overriddenNamedP TEntry.getKey() == parameter.name) {
19413 parameterToSelect = parameter; 19337 parameterToSelect = parameter;
19414 parameterLocationToSelect = parameterLocations[i]; 19338 parameterLocationToSelect = parameterLocations[i];
19415 break; 19339 break;
19416 } 19340 }
19417 } 19341 }
19418 if (parameterToSelect != null) { 19342 if (parameterToSelect != null) {
19419 _errorReporter.reportErrorForNode(StaticWarningCode.INVALID_METHOD_OVE RRIDE_NAMED_PARAM_TYPE, parameterLocationToSelect, [ 19343 _errorReporter.reportErrorForNode(StaticWarningCode.INVALID_METHOD_OVE RRIDE_NAMED_PARAM_TYPE, parameterLocationToSelect, [
19420 overridingType.displayName, 19344 overridingType.displayName,
19421 overriddenNamedPTIterator.value.displayName, 19345 overriddenNamedPTEntry.getValue().displayName,
19422 overriddenExecutable.enclosingElement.displayName]); 19346 overriddenExecutable.enclosingElement.displayName]);
19423 return true; 19347 return true;
19424 } 19348 }
19425 } 19349 }
19426 } 19350 }
19427 // SWC.INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES 19351 // SWC.INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES
19428 // 19352 //
19429 // Create three arrays: an array of the optional parameter ASTs (FormalParam eters), an array of 19353 // Create three arrays: an array of the optional parameter ASTs (FormalParam eters), an array of
19430 // the optional parameters elements from our method, and finally an array of the optional 19354 // the optional parameters elements from our method, and finally an array of the optional
19431 // parameter elements from the method we are overriding. 19355 // parameter elements from the method we are overriding.
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
19660 TypeName constructorTypeName = redirectedConstructor.type; 19584 TypeName constructorTypeName = redirectedConstructor.type;
19661 DartType redirectedType = constructorTypeName.type; 19585 DartType redirectedType = constructorTypeName.type;
19662 if (redirectedType != null && redirectedType.element != null && !redirecte dType.isDynamic) { 19586 if (redirectedType != null && redirectedType.element != null && !redirecte dType.isDynamic) {
19663 // 19587 //
19664 // Prepare the constructor name 19588 // Prepare the constructor name
19665 // 19589 //
19666 String constructorStrName = constructorTypeName.name.name; 19590 String constructorStrName = constructorTypeName.name.name;
19667 if (redirectedConstructor.name != null) { 19591 if (redirectedConstructor.name != null) {
19668 constructorStrName += ".${redirectedConstructor.name.name}"; 19592 constructorStrName += ".${redirectedConstructor.name.name}";
19669 } 19593 }
19670 ErrorCode errorCode = (node.constKeyword != null ? CompileTimeErrorCode. REDIRECT_TO_MISSING_CONSTRUCTOR : StaticWarningCode.REDIRECT_TO_MISSING_CONSTRUC TOR) as ErrorCode; 19594 ErrorCode errorCode = (node.constKeyword != null ? CompileTimeErrorCode. REDIRECT_TO_MISSING_CONSTRUCTOR : StaticWarningCode.REDIRECT_TO_MISSING_CONSTRUC TOR);
19671 _errorReporter.reportErrorForNode(errorCode, redirectedConstructor, [con structorStrName, redirectedType.displayName]); 19595 _errorReporter.reportErrorForNode(errorCode, redirectedConstructor, [con structorStrName, redirectedType.displayName]);
19672 return true; 19596 return true;
19673 } 19597 }
19674 return false; 19598 return false;
19675 } 19599 }
19676 FunctionType redirectedType = redirectedElement.type; 19600 FunctionType redirectedType = redirectedElement.type;
19677 DartType redirectedReturnType = redirectedType.returnType; 19601 DartType redirectedReturnType = redirectedType.returnType;
19678 // 19602 //
19679 // Report specific problem when return type is incompatible 19603 // Report specific problem when return type is incompatible
19680 // 19604 //
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
19749 */ 19673 */
19750 bool _checkForAmbiguousExport(ExportDirective node, ExportElement exportElemen t) { 19674 bool _checkForAmbiguousExport(ExportDirective node, ExportElement exportElemen t) {
19751 // prepare exported library 19675 // prepare exported library
19752 LibraryElement exportedLibrary = exportElement.exportedLibrary; 19676 LibraryElement exportedLibrary = exportElement.exportedLibrary;
19753 if (exportedLibrary == null) { 19677 if (exportedLibrary == null) {
19754 return false; 19678 return false;
19755 } 19679 }
19756 // check exported names 19680 // check exported names
19757 Namespace namespace = new NamespaceBuilder().createExportNamespaceForDirecti ve(exportElement); 19681 Namespace namespace = new NamespaceBuilder().createExportNamespaceForDirecti ve(exportElement);
19758 Map<String, Element> definedNames = namespace.definedNames; 19682 Map<String, Element> definedNames = namespace.definedNames;
19759 for (MapIterator<String, Element> iter = SingleMapIterator.forMap(definedNam es); iter.moveNext();) { 19683 for (MapEntry<String, Element> definedEntry in getMapEntrySet(definedNames)) {
19760 String name = iter.key; 19684 String name = definedEntry.getKey();
19761 Element element = iter.value; 19685 Element element = definedEntry.getValue();
19762 Element prevElement = _exportedElements[name]; 19686 Element prevElement = _exportedElements[name];
19763 if (element != null && prevElement != null && prevElement != element) { 19687 if (element != null && prevElement != null && prevElement != element) {
19764 _errorReporter.reportErrorForNode(CompileTimeErrorCode.AMBIGUOUS_EXPORT, node, [ 19688 _errorReporter.reportErrorForNode(CompileTimeErrorCode.AMBIGUOUS_EXPORT, node, [
19765 name, 19689 name,
19766 prevElement.library.definingCompilationUnit.displayName, 19690 prevElement.library.definingCompilationUnit.displayName,
19767 element.library.definingCompilationUnit.displayName]); 19691 element.library.definingCompilationUnit.displayName]);
19768 return true; 19692 return true;
19769 } else { 19693 } else {
19770 _exportedElements[name] = element; 19694 _exportedElements[name] = element;
19771 } 19695 }
(...skipping 3037 matching lines...) Expand 10 before | Expand all | Expand 10 after
22809 if (node.abstractKeyword != null) { 22733 if (node.abstractKeyword != null) {
22810 return false; 22734 return false;
22811 } 22735 }
22812 ClassElement classElement = node.element; 22736 ClassElement classElement = node.element;
22813 if (classElement == null) { 22737 if (classElement == null) {
22814 return false; 22738 return false;
22815 } 22739 }
22816 if (!classElement.type.isSubtypeOf(_typeProvider.functionType)) { 22740 if (!classElement.type.isSubtypeOf(_typeProvider.functionType)) {
22817 return false; 22741 return false;
22818 } 22742 }
22743 // If there is a noSuchMethod method, then don't report the warning, see dar tbug.com/16078
22744 if (classElement.getMethod(ElementResolver.NO_SUCH_METHOD_METHOD_NAME) != nu ll) {
22745 return false;
22746 }
22819 ExecutableElement callMethod = _inheritanceManager.lookupMember(classElement , "call"); 22747 ExecutableElement callMethod = _inheritanceManager.lookupMember(classElement , "call");
22820 if (callMethod == null || callMethod is! MethodElement || (callMethod as Met hodElement).isAbstract) { 22748 if (callMethod == null || callMethod is! MethodElement || (callMethod as Met hodElement).isAbstract) {
22821 _errorReporter.reportErrorForNode(StaticWarningCode.FUNCTION_WITHOUT_CALL, node.name, []); 22749 _errorReporter.reportErrorForNode(StaticWarningCode.FUNCTION_WITHOUT_CALL, node.name, []);
22822 return true; 22750 return true;
22823 } 22751 }
22824 return false; 22752 return false;
22825 } 22753 }
22826 22754
22827 /** 22755 /**
22828 * This verifies that the given class declaration does not have the same class in the 'extends' 22756 * This verifies that the given class declaration does not have the same class in the 'extends'
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
23313 * 23241 *
23314 * @param type the type of this error 23242 * @param type the type of this error
23315 * @param message the template used to create the message to be displayed for the error 23243 * @param message the template used to create the message to be displayed for the error
23316 * @param correction the template used to create the correction to be displaye d for the error 23244 * @param correction the template used to create the correction to be displaye d for the error
23317 */ 23245 */
23318 const ResolverErrorCode.con2(String name, int ordinal, this.type, this.message , this.correction) : super(name, ordinal); 23246 const ResolverErrorCode.con2(String name, int ordinal, this.type, this.message , this.correction) : super(name, ordinal);
23319 23247
23320 @override 23248 @override
23321 ErrorSeverity get errorSeverity => type.severity; 23249 ErrorSeverity get errorSeverity => type.severity;
23322 } 23250 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/parser.dart ('k') | pkg/analyzer/lib/src/generated/sdk_io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698