| OLD | NEW |
| 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 library engine.resolver.element_resolver; | 5 library engine.resolver.element_resolver; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'ast.dart'; | 9 import 'ast.dart'; |
| 10 import 'element.dart'; | 10 import 'element.dart'; |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 // StaticWarningCode.UNDEFINED_IDENTIFIER, | 223 // StaticWarningCode.UNDEFINED_IDENTIFIER, |
| 224 // simpleIdentifier, | 224 // simpleIdentifier, |
| 225 // simpleIdentifier.getName()); | 225 // simpleIdentifier.getName()); |
| 226 } else { | 226 } else { |
| 227 if (element.library == null || element.library != _definingLibrary) { | 227 if (element.library == null || element.library != _definingLibrary) { |
| 228 // TODO(brianwilkerson) Report this error? | 228 // TODO(brianwilkerson) Report this error? |
| 229 } | 229 } |
| 230 simpleIdentifier.staticElement = element; | 230 simpleIdentifier.staticElement = element; |
| 231 if (node.newKeyword != null) { | 231 if (node.newKeyword != null) { |
| 232 if (element is ClassElement) { | 232 if (element is ClassElement) { |
| 233 ConstructorElement constructor = | 233 ConstructorElement constructor = element.unnamedConstructor; |
| 234 (element as ClassElement).unnamedConstructor; | |
| 235 if (constructor == null) { | 234 if (constructor == null) { |
| 236 // TODO(brianwilkerson) Report this error. | 235 // TODO(brianwilkerson) Report this error. |
| 237 } else { | 236 } else { |
| 238 simpleIdentifier.staticElement = constructor; | 237 simpleIdentifier.staticElement = constructor; |
| 239 } | 238 } |
| 240 } else { | 239 } else { |
| 241 // TODO(brianwilkerson) Report this error. | 240 // TODO(brianwilkerson) Report this error. |
| 242 } | 241 } |
| 243 } | 242 } |
| 244 } | 243 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 262 // TODO(brianwilkerson) We need to understand how the library could | 261 // TODO(brianwilkerson) We need to understand how the library could |
| 263 // ever be null. | 262 // ever be null. |
| 264 AnalysisEngine.instance.logger | 263 AnalysisEngine.instance.logger |
| 265 .logError("Found element with null library: ${element.name}"); | 264 .logError("Found element with null library: ${element.name}"); |
| 266 } else if (library != _definingLibrary) { | 265 } else if (library != _definingLibrary) { |
| 267 // TODO(brianwilkerson) Report this error. | 266 // TODO(brianwilkerson) Report this error. |
| 268 } | 267 } |
| 269 name.staticElement = element; | 268 name.staticElement = element; |
| 270 if (node.newKeyword == null) { | 269 if (node.newKeyword == null) { |
| 271 if (element is ClassElement) { | 270 if (element is ClassElement) { |
| 272 Element memberElement = _lookupGetterOrMethod( | 271 Element memberElement = |
| 273 (element as ClassElement).type, name.name); | 272 _lookupGetterOrMethod(element.type, name.name); |
| 274 if (memberElement == null) { | 273 if (memberElement == null) { |
| 275 memberElement = | 274 memberElement = element.getNamedConstructor(name.name); |
| 276 (element as ClassElement).getNamedConstructor(name.name); | |
| 277 if (memberElement == null) { | 275 if (memberElement == null) { |
| 278 memberElement = _lookUpSetter( | 276 memberElement = _lookUpSetter(prefix, element.type, name.name); |
| 279 prefix, (element as ClassElement).type, name.name); | |
| 280 } | 277 } |
| 281 } | 278 } |
| 282 if (memberElement == null) { | 279 if (memberElement == null) { |
| 283 // reportGetterOrSetterNotFound(prefixedIdentifier, name, element.g
etDisplayName()); | 280 // reportGetterOrSetterNotFound(prefixedIdentifier, name, element.g
etDisplayName()); |
| 284 } else { | 281 } else { |
| 285 name.staticElement = memberElement; | 282 name.staticElement = memberElement; |
| 286 } | 283 } |
| 287 } else { | 284 } else { |
| 288 // TODO(brianwilkerson) Report this error. | 285 // TODO(brianwilkerson) Report this error. |
| 289 } | 286 } |
| 290 } else { | 287 } else { |
| 291 if (element is ClassElement) { | 288 if (element is ClassElement) { |
| 292 ConstructorElement constructor = | 289 ConstructorElement constructor = |
| 293 (element as ClassElement).getNamedConstructor(name.name); | 290 element.getNamedConstructor(name.name); |
| 294 if (constructor == null) { | 291 if (constructor == null) { |
| 295 // TODO(brianwilkerson) Report this error. | 292 // TODO(brianwilkerson) Report this error. |
| 296 } else { | 293 } else { |
| 297 name.staticElement = constructor; | 294 name.staticElement = constructor; |
| 298 } | 295 } |
| 299 } else { | 296 } else { |
| 300 // TODO(brianwilkerson) Report this error. | 297 // TODO(brianwilkerson) Report this error. |
| 301 } | 298 } |
| 302 } | 299 } |
| 303 } | 300 } |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 // | 624 // |
| 628 ErrorCode errorCode = _checkForInvocationError(target, true, staticElement); | 625 ErrorCode errorCode = _checkForInvocationError(target, true, staticElement); |
| 629 bool generatedWithTypePropagation = false; | 626 bool generatedWithTypePropagation = false; |
| 630 if (_enableHints && errorCode == null && staticElement == null) { | 627 if (_enableHints && errorCode == null && staticElement == null) { |
| 631 // The method lookup may have failed because there were multiple | 628 // The method lookup may have failed because there were multiple |
| 632 // incompatible choices. In this case we don't want to generate a hint. | 629 // incompatible choices. In this case we don't want to generate a hint. |
| 633 if (propagatedElement == null && propagatedType is UnionType) { | 630 if (propagatedElement == null && propagatedType is UnionType) { |
| 634 // TODO(collinsn): an improvement here is to make the propagated type | 631 // TODO(collinsn): an improvement here is to make the propagated type |
| 635 // of the method call the union of the propagated types of all possible | 632 // of the method call the union of the propagated types of all possible |
| 636 // calls. | 633 // calls. |
| 637 if (_lookupMethods( | 634 if (_lookupMethods(target, propagatedType, methodName.name).length > |
| 638 target, propagatedType as UnionType, methodName.name).length > | |
| 639 1) { | 635 1) { |
| 640 return null; | 636 return null; |
| 641 } | 637 } |
| 642 } | 638 } |
| 643 errorCode = _checkForInvocationError(target, false, propagatedElement); | 639 errorCode = _checkForInvocationError(target, false, propagatedElement); |
| 644 if (identical(errorCode, StaticTypeWarningCode.UNDEFINED_METHOD)) { | 640 if (identical(errorCode, StaticTypeWarningCode.UNDEFINED_METHOD)) { |
| 645 ClassElement classElementContext = null; | 641 ClassElement classElementContext = null; |
| 646 if (target == null) { | 642 if (target == null) { |
| 647 classElementContext = _resolver.enclosingClass; | 643 classElementContext = _resolver.enclosingClass; |
| 648 } else { | 644 } else { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 665 } | 661 } |
| 666 } | 662 } |
| 667 generatedWithTypePropagation = true; | 663 generatedWithTypePropagation = true; |
| 668 } | 664 } |
| 669 if (errorCode == null) { | 665 if (errorCode == null) { |
| 670 return null; | 666 return null; |
| 671 } | 667 } |
| 672 if (identical( | 668 if (identical( |
| 673 errorCode, StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION)) { | 669 errorCode, StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION)) { |
| 674 _resolver.reportErrorForNode( | 670 _resolver.reportErrorForNode( |
| 675 StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION, methodName, [ | 671 StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION, methodName, |
| 676 methodName.name | 672 [methodName.name]); |
| 677 ]); | |
| 678 } else if (identical(errorCode, StaticTypeWarningCode.UNDEFINED_FUNCTION)) { | 673 } else if (identical(errorCode, StaticTypeWarningCode.UNDEFINED_FUNCTION)) { |
| 679 _resolver.reportErrorForNode(StaticTypeWarningCode.UNDEFINED_FUNCTION, | 674 _resolver.reportErrorForNode(StaticTypeWarningCode.UNDEFINED_FUNCTION, |
| 680 methodName, [methodName.name]); | 675 methodName, [methodName.name]); |
| 681 } else if (identical(errorCode, StaticTypeWarningCode.UNDEFINED_METHOD)) { | 676 } else if (identical(errorCode, StaticTypeWarningCode.UNDEFINED_METHOD)) { |
| 682 String targetTypeName; | 677 String targetTypeName; |
| 683 if (target == null) { | 678 if (target == null) { |
| 684 ClassElement enclosingClass = _resolver.enclosingClass; | 679 ClassElement enclosingClass = _resolver.enclosingClass; |
| 685 targetTypeName = enclosingClass.displayName; | 680 targetTypeName = enclosingClass.displayName; |
| 686 ErrorCode proxyErrorCode = (generatedWithTypePropagation | 681 ErrorCode proxyErrorCode = (generatedWithTypePropagation |
| 687 ? HintCode.UNDEFINED_METHOD | 682 ? HintCode.UNDEFINED_METHOD |
| (...skipping 20 matching lines...) Expand all Loading... |
| 708 methodName.name == FunctionElement.CALL_METHOD_NAME) { | 703 methodName.name == FunctionElement.CALL_METHOD_NAME) { |
| 709 // TODO(brianwilkerson) Can we ever resolve the function being | 704 // TODO(brianwilkerson) Can we ever resolve the function being |
| 710 // invoked? | 705 // invoked? |
| 711 // resolveArgumentsToParameters(node.getArgumentList(), invokedFunction
); | 706 // resolveArgumentsToParameters(node.getArgumentList(), invokedFunction
); |
| 712 return null; | 707 return null; |
| 713 } | 708 } |
| 714 targetTypeName = targetType == null ? null : targetType.displayName; | 709 targetTypeName = targetType == null ? null : targetType.displayName; |
| 715 ErrorCode proxyErrorCode = (generatedWithTypePropagation | 710 ErrorCode proxyErrorCode = (generatedWithTypePropagation |
| 716 ? HintCode.UNDEFINED_METHOD | 711 ? HintCode.UNDEFINED_METHOD |
| 717 : StaticTypeWarningCode.UNDEFINED_METHOD); | 712 : StaticTypeWarningCode.UNDEFINED_METHOD); |
| 718 _recordUndefinedNode(targetType.element, proxyErrorCode, | 713 _recordUndefinedNode(targetType.element, proxyErrorCode, methodName, [ |
| 719 methodName, [methodName.name, targetTypeName]); | 714 methodName.name, |
| 715 targetTypeName |
| 716 ]); |
| 720 } | 717 } |
| 721 } else if (identical( | 718 } else if (identical( |
| 722 errorCode, StaticTypeWarningCode.UNDEFINED_SUPER_METHOD)) { | 719 errorCode, StaticTypeWarningCode.UNDEFINED_SUPER_METHOD)) { |
| 723 // Generate the type name. | 720 // Generate the type name. |
| 724 // The error code will never be generated via type propagation | 721 // The error code will never be generated via type propagation |
| 725 DartType targetType = _getStaticType(target); | 722 DartType targetType = _getStaticType(target); |
| 726 if (targetType is InterfaceType && !targetType.isObject) { | 723 if (targetType is InterfaceType && !targetType.isObject) { |
| 727 targetType = (targetType as InterfaceType).superclass; | 724 targetType = (targetType as InterfaceType).superclass; |
| 728 } | 725 } |
| 729 String targetTypeName = targetType == null ? null : targetType.name; | 726 String targetTypeName = targetType == null ? null : targetType.name; |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1240 errorCode = HintCode.UNDEFINED_OPERATOR; | 1237 errorCode = HintCode.UNDEFINED_OPERATOR; |
| 1241 } | 1238 } |
| 1242 DartType type = | 1239 DartType type = |
| 1243 shouldReportMissingMember_static ? staticType : propagatedType; | 1240 shouldReportMissingMember_static ? staticType : propagatedType; |
| 1244 if (leftBracket == null || rightBracket == null) { | 1241 if (leftBracket == null || rightBracket == null) { |
| 1245 _recordUndefinedNode( | 1242 _recordUndefinedNode( |
| 1246 type.element, errorCode, node, [methodName, type.displayName]); | 1243 type.element, errorCode, node, [methodName, type.displayName]); |
| 1247 } else { | 1244 } else { |
| 1248 int offset = leftBracket.offset; | 1245 int offset = leftBracket.offset; |
| 1249 int length = rightBracket.offset - offset + 1; | 1246 int length = rightBracket.offset - offset + 1; |
| 1250 _recordUndefinedOffset(type.element, errorCode, | 1247 _recordUndefinedOffset(type.element, errorCode, offset, length, [ |
| 1251 offset, length, [methodName, type.displayName]); | 1248 methodName, |
| 1249 type.displayName |
| 1250 ]); |
| 1252 } | 1251 } |
| 1253 return true; | 1252 return true; |
| 1254 } | 1253 } |
| 1255 return false; | 1254 return false; |
| 1256 } | 1255 } |
| 1257 | 1256 |
| 1258 /** | 1257 /** |
| 1259 * Given a list of arguments and the element that will be invoked using those
argument, compute | 1258 * Given a list of arguments and the element that will be invoked using those
argument, compute |
| 1260 * the list of parameters that correspond to the list of arguments. Return the
parameters that | 1259 * the list of parameters that correspond to the list of arguments. Return the
parameters that |
| 1261 * correspond to the arguments, or `null` if no correspondence could be comput
ed. | 1260 * correspond to the arguments, or `null` if no correspondence could be comput
ed. |
| (...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2130 Element element2 = nameNode2.staticElement; | 2129 Element element2 = nameNode2.staticElement; |
| 2131 // Class.CONST - not resolved yet | 2130 // Class.CONST - not resolved yet |
| 2132 if (element1 is ClassElement) { | 2131 if (element1 is ClassElement) { |
| 2133 ClassElement classElement = element1; | 2132 ClassElement classElement = element1; |
| 2134 element2 = classElement.lookUpGetter(nameNode2.name, _definingLibrary); | 2133 element2 = classElement.lookUpGetter(nameNode2.name, _definingLibrary); |
| 2135 } | 2134 } |
| 2136 // prefix.CONST or Class.CONST | 2135 // prefix.CONST or Class.CONST |
| 2137 if (element2 is PropertyAccessorElement) { | 2136 if (element2 is PropertyAccessorElement) { |
| 2138 nameNode2.staticElement = element2; | 2137 nameNode2.staticElement = element2; |
| 2139 annotation.element = element2; | 2138 annotation.element = element2; |
| 2140 _resolveAnnotationElementGetter( | 2139 _resolveAnnotationElementGetter(annotation, element2); |
| 2141 annotation, element2 as PropertyAccessorElement); | |
| 2142 return; | 2140 return; |
| 2143 } | 2141 } |
| 2144 // prefix.Class() | 2142 // prefix.Class() |
| 2145 if (element2 is ClassElement) { | 2143 if (element2 is ClassElement) { |
| 2146 ClassElement classElement = element2 as ClassElement; | 2144 constructor = element2.unnamedConstructor; |
| 2147 constructor = classElement.unnamedConstructor; | |
| 2148 } | 2145 } |
| 2149 // Class.constructor(args) | 2146 // Class.constructor(args) |
| 2150 if (element1 is ClassElement) { | 2147 if (element1 is ClassElement) { |
| 2151 ClassElement classElement = element1; | 2148 ClassElement classElement = element1; |
| 2152 constructor = new InterfaceTypeImpl.con1(classElement) | 2149 constructor = new InterfaceTypeImpl.con1(classElement) |
| 2153 .lookUpConstructor(nameNode2.name, _definingLibrary); | 2150 .lookUpConstructor(nameNode2.name, _definingLibrary); |
| 2154 nameNode2.staticElement = constructor; | 2151 nameNode2.staticElement = constructor; |
| 2155 } | 2152 } |
| 2156 } | 2153 } |
| 2157 // | 2154 // |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2294 if (unnamedIndex < unnamedParameterCount) { | 2291 if (unnamedIndex < unnamedParameterCount) { |
| 2295 resolvedParameters[i] = unnamedParameters[unnamedIndex++]; | 2292 resolvedParameters[i] = unnamedParameters[unnamedIndex++]; |
| 2296 } | 2293 } |
| 2297 } | 2294 } |
| 2298 } | 2295 } |
| 2299 if (positionalArgumentCount < requiredParameters.length && | 2296 if (positionalArgumentCount < requiredParameters.length && |
| 2300 noBlankArguments) { | 2297 noBlankArguments) { |
| 2301 ErrorCode errorCode = (reportError | 2298 ErrorCode errorCode = (reportError |
| 2302 ? CompileTimeErrorCode.NOT_ENOUGH_REQUIRED_ARGUMENTS | 2299 ? CompileTimeErrorCode.NOT_ENOUGH_REQUIRED_ARGUMENTS |
| 2303 : StaticWarningCode.NOT_ENOUGH_REQUIRED_ARGUMENTS); | 2300 : StaticWarningCode.NOT_ENOUGH_REQUIRED_ARGUMENTS); |
| 2304 _resolver.reportErrorForNode(errorCode, argumentList, | 2301 _resolver.reportErrorForNode(errorCode, argumentList, [ |
| 2305 [requiredParameters.length, positionalArgumentCount]); | 2302 requiredParameters.length, |
| 2303 positionalArgumentCount |
| 2304 ]); |
| 2306 } else if (positionalArgumentCount > unnamedParameterCount && | 2305 } else if (positionalArgumentCount > unnamedParameterCount && |
| 2307 noBlankArguments) { | 2306 noBlankArguments) { |
| 2308 ErrorCode errorCode = (reportError | 2307 ErrorCode errorCode = (reportError |
| 2309 ? CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS | 2308 ? CompileTimeErrorCode.EXTRA_POSITIONAL_ARGUMENTS |
| 2310 : StaticWarningCode.EXTRA_POSITIONAL_ARGUMENTS); | 2309 : StaticWarningCode.EXTRA_POSITIONAL_ARGUMENTS); |
| 2311 _resolver.reportErrorForNode(errorCode, argumentList, | 2310 _resolver.reportErrorForNode(errorCode, argumentList, [ |
| 2312 [unnamedParameterCount, positionalArgumentCount]); | 2311 unnamedParameterCount, |
| 2312 positionalArgumentCount |
| 2313 ]); |
| 2313 } | 2314 } |
| 2314 return resolvedParameters; | 2315 return resolvedParameters; |
| 2315 } | 2316 } |
| 2316 | 2317 |
| 2317 void _resolveBinaryExpression(BinaryExpression node, String methodName) { | 2318 void _resolveBinaryExpression(BinaryExpression node, String methodName) { |
| 2318 Expression leftOperand = node.leftOperand; | 2319 Expression leftOperand = node.leftOperand; |
| 2319 if (leftOperand != null) { | 2320 if (leftOperand != null) { |
| 2320 DartType staticType = _getStaticType(leftOperand); | 2321 DartType staticType = _getStaticType(leftOperand); |
| 2321 MethodElement staticMethod = | 2322 MethodElement staticMethod = |
| 2322 _lookUpMethod(leftOperand, staticType, methodName); | 2323 _lookUpMethod(leftOperand, staticType, methodName); |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2590 if (!_enableStrictCallChecks && | 2591 if (!_enableStrictCallChecks && |
| 2591 targetType != null && | 2592 targetType != null && |
| 2592 targetType.isDartCoreFunction && | 2593 targetType.isDartCoreFunction && |
| 2593 propertyName.name == FunctionElement.CALL_METHOD_NAME) { | 2594 propertyName.name == FunctionElement.CALL_METHOD_NAME) { |
| 2594 // TODO(brianwilkerson) Can we ever resolve the function being | 2595 // TODO(brianwilkerson) Can we ever resolve the function being |
| 2595 // invoked? | 2596 // invoked? |
| 2596 // resolveArgumentsToParameters(node.getArgumentList(), invokedFuncti
on); | 2597 // resolveArgumentsToParameters(node.getArgumentList(), invokedFuncti
on); |
| 2597 return; | 2598 return; |
| 2598 } else if (classElement.isEnum && propertyName.name == "_name") { | 2599 } else if (classElement.isEnum && propertyName.name == "_name") { |
| 2599 _resolver.reportErrorForNode( | 2600 _resolver.reportErrorForNode( |
| 2600 CompileTimeErrorCode.ACCESS_PRIVATE_ENUM_FIELD, propertyName, [ | 2601 CompileTimeErrorCode.ACCESS_PRIVATE_ENUM_FIELD, propertyName, |
| 2601 propertyName.name | 2602 [propertyName.name]); |
| 2602 ]); | |
| 2603 return; | 2603 return; |
| 2604 } | 2604 } |
| 2605 } | 2605 } |
| 2606 } | 2606 } |
| 2607 Element declaringElement = | 2607 Element declaringElement = |
| 2608 staticType.isVoid ? null : staticOrPropagatedEnclosingElt; | 2608 staticType.isVoid ? null : staticOrPropagatedEnclosingElt; |
| 2609 if (propertyName.inSetterContext()) { | 2609 if (propertyName.inSetterContext()) { |
| 2610 ErrorCode errorCode; | 2610 ErrorCode errorCode; |
| 2611 if (shouldReportMissingMember_static) { | 2611 if (shouldReportMissingMember_static) { |
| 2612 if (target is SuperExpression) { | 2612 if (target is SuperExpression) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2647 } | 2647 } |
| 2648 } else { | 2648 } else { |
| 2649 errorCode = HintCode.UNDEFINED_GETTER; | 2649 errorCode = HintCode.UNDEFINED_GETTER; |
| 2650 } | 2650 } |
| 2651 _recordUndefinedNode(declaringElement, errorCode, propertyName, [ | 2651 _recordUndefinedNode(declaringElement, errorCode, propertyName, [ |
| 2652 propertyName.name, | 2652 propertyName.name, |
| 2653 displayType.displayName | 2653 displayType.displayName |
| 2654 ]); | 2654 ]); |
| 2655 } else { | 2655 } else { |
| 2656 _recordUndefinedNode(declaringElement, | 2656 _recordUndefinedNode(declaringElement, |
| 2657 StaticWarningCode.UNDEFINED_IDENTIFIER, propertyName, [ | 2657 StaticWarningCode.UNDEFINED_IDENTIFIER, propertyName, |
| 2658 propertyName.name | 2658 [propertyName.name]); |
| 2659 ]); | |
| 2660 } | 2659 } |
| 2661 } | 2660 } |
| 2662 } | 2661 } |
| 2663 | 2662 |
| 2664 /** | 2663 /** |
| 2665 * Resolve the given simple identifier if possible. Return the element to whic
h it could be | 2664 * Resolve the given simple identifier if possible. Return the element to whic
h it could be |
| 2666 * resolved, or `null` if it could not be resolved. This does not record the r
esults of the | 2665 * resolved, or `null` if it could not be resolved. This does not record the r
esults of the |
| 2667 * resolution. | 2666 * resolution. |
| 2668 * | 2667 * |
| 2669 * @param node the identifier to be resolved | 2668 * @param node the identifier to be resolved |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2924 * | 2923 * |
| 2925 * @param node the 'super' expression to analyze | 2924 * @param node the 'super' expression to analyze |
| 2926 * @return `true` if the 'super' expression is in a valid context | 2925 * @return `true` if the 'super' expression is in a valid context |
| 2927 */ | 2926 */ |
| 2928 static bool _isSuperInValidContext(SuperExpression node) { | 2927 static bool _isSuperInValidContext(SuperExpression node) { |
| 2929 for (AstNode n = node; n != null; n = n.parent) { | 2928 for (AstNode n = node; n != null; n = n.parent) { |
| 2930 if (n is CompilationUnit) { | 2929 if (n is CompilationUnit) { |
| 2931 return false; | 2930 return false; |
| 2932 } | 2931 } |
| 2933 if (n is ConstructorDeclaration) { | 2932 if (n is ConstructorDeclaration) { |
| 2934 ConstructorDeclaration constructor = n as ConstructorDeclaration; | 2933 return n.factoryKeyword == null; |
| 2935 return constructor.factoryKeyword == null; | |
| 2936 } | 2934 } |
| 2937 if (n is ConstructorFieldInitializer) { | 2935 if (n is ConstructorFieldInitializer) { |
| 2938 return false; | 2936 return false; |
| 2939 } | 2937 } |
| 2940 if (n is MethodDeclaration) { | 2938 if (n is MethodDeclaration) { |
| 2941 MethodDeclaration method = n as MethodDeclaration; | 2939 return !n.isStatic; |
| 2942 return !method.isStatic; | |
| 2943 } | 2940 } |
| 2944 } | 2941 } |
| 2945 return false; | 2942 return false; |
| 2946 } | 2943 } |
| 2947 | 2944 |
| 2948 /** | 2945 /** |
| 2949 * Return a method representing the merge of the given elements. The type of t
he merged element is | 2946 * Return a method representing the merge of the given elements. The type of t
he merged element is |
| 2950 * the component-wise union of the types of the given elements. If not all inp
ut elements have the | 2947 * the component-wise union of the types of the given elements. If not all inp
ut elements have the |
| 2951 * same shape then [null] is returned. | 2948 * same shape then [null] is returned. |
| 2952 * | 2949 * |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3022 | 3019 |
| 3023 @override | 3020 @override |
| 3024 Element get staticElement => null; | 3021 Element get staticElement => null; |
| 3025 | 3022 |
| 3026 @override | 3023 @override |
| 3027 accept(AstVisitor visitor) => null; | 3024 accept(AstVisitor visitor) => null; |
| 3028 | 3025 |
| 3029 @override | 3026 @override |
| 3030 void visitChildren(AstVisitor visitor) {} | 3027 void visitChildren(AstVisitor visitor) {} |
| 3031 } | 3028 } |
| OLD | NEW |