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 analyzer.src.generated.element_resolver; | 5 library analyzer.src.generated.element_resolver; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
10 import 'package:analyzer/dart/ast/syntactic_entity.dart'; | 10 import 'package:analyzer/dart/ast/syntactic_entity.dart'; |
(...skipping 1298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1309 // be the case that static type is some type, in which the static | 1309 // be the case that static type is some type, in which the static |
1310 // type should be used. | 1310 // type should be used. |
1311 targetType = _getBestType(target); | 1311 targetType = _getBestType(target); |
1312 } | 1312 } |
1313 if (targetType == null) { | 1313 if (targetType == null) { |
1314 if (target is Identifier && | 1314 if (target is Identifier && |
1315 _resolver.nameScope.shouldIgnoreUndefined(target)) { | 1315 _resolver.nameScope.shouldIgnoreUndefined(target)) { |
1316 return null; | 1316 return null; |
1317 } | 1317 } |
1318 return StaticTypeWarningCode.UNDEFINED_FUNCTION; | 1318 return StaticTypeWarningCode.UNDEFINED_FUNCTION; |
1319 } else if (!targetType.isDynamic && !targetType.isBottom) { | 1319 } else if (!targetType.isDynamic && target is! NullLiteral) { |
1320 // Proxy-conditional warning, based on state of | 1320 // Proxy-conditional warning, based on state of |
1321 // targetType.getElement() | 1321 // targetType.getElement() |
1322 return StaticTypeWarningCode.UNDEFINED_METHOD; | 1322 return StaticTypeWarningCode.UNDEFINED_METHOD; |
1323 } | 1323 } |
1324 } | 1324 } |
1325 } | 1325 } |
1326 } | 1326 } |
1327 return null; | 1327 return null; |
1328 } | 1328 } |
1329 | 1329 |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1554 // All function types are subtypes of 'Function', which is itself a | 1554 // All function types are subtypes of 'Function', which is itself a |
1555 // subclass of 'Object'. | 1555 // subclass of 'Object'. |
1556 // | 1556 // |
1557 staticType = _resolver.typeProvider.functionType; | 1557 staticType = _resolver.typeProvider.functionType; |
1558 } | 1558 } |
1559 return staticType; | 1559 return staticType; |
1560 } | 1560 } |
1561 | 1561 |
1562 DartType _getStaticTypeOrFunctionType(Expression expression) { | 1562 DartType _getStaticTypeOrFunctionType(Expression expression) { |
1563 if (expression is NullLiteral) { | 1563 if (expression is NullLiteral) { |
1564 return _resolver.typeProvider.bottomType; | 1564 return _resolver.typeProvider.nullType; |
1565 } | 1565 } |
1566 return _resolveTypeParameter(expression.staticType); | 1566 return _resolveTypeParameter(expression.staticType); |
1567 } | 1567 } |
1568 | 1568 |
1569 /** | 1569 /** |
1570 * Check for a generic method & apply type arguments if any were passed. | 1570 * Check for a generic method & apply type arguments if any were passed. |
1571 */ | 1571 */ |
1572 DartType _instantiateGenericMethod( | 1572 DartType _instantiateGenericMethod( |
1573 DartType invokeType, TypeArgumentList typeArguments, AstNode node) { | 1573 DartType invokeType, TypeArgumentList typeArguments, AstNode node) { |
1574 // TODO(jmesserly): support generic "call" methods on InterfaceType. | 1574 // TODO(jmesserly): support generic "call" methods on InterfaceType. |
(...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2491 * be used when looking up members. Otherwise, return the original type. | 2491 * be used when looking up members. Otherwise, return the original type. |
2492 */ | 2492 */ |
2493 DartType _resolveTypeParameter(DartType type) => | 2493 DartType _resolveTypeParameter(DartType type) => |
2494 type?.resolveToBound(_resolver.typeProvider.objectType); | 2494 type?.resolveToBound(_resolver.typeProvider.objectType); |
2495 | 2495 |
2496 /** | 2496 /** |
2497 * Return `true` if we should report an error as a result of looking up a | 2497 * Return `true` if we should report an error as a result of looking up a |
2498 * [member] in the given [type] and not finding any member. | 2498 * [member] in the given [type] and not finding any member. |
2499 */ | 2499 */ |
2500 bool _shouldReportMissingMember(DartType type, Element member) { | 2500 bool _shouldReportMissingMember(DartType type, Element member) { |
2501 return member == null && type != null && !type.isDynamic && !type.isBottom; | 2501 return member == null && type != null && !type.isDynamic && !type.isDartCore
Null; |
2502 } | 2502 } |
2503 | 2503 |
2504 /** | 2504 /** |
2505 * Checks whether the given [expression] is a reference to a class. If it is | 2505 * Checks whether the given [expression] is a reference to a class. If it is |
2506 * then the element representing the class is returned, otherwise `null` is | 2506 * then the element representing the class is returned, otherwise `null` is |
2507 * returned. | 2507 * returned. |
2508 */ | 2508 */ |
2509 static ClassElement getTypeReference(Expression expression) { | 2509 static ClassElement getTypeReference(Expression expression) { |
2510 if (expression is Identifier) { | 2510 if (expression is Identifier) { |
2511 Element staticElement = expression.staticElement; | 2511 Element staticElement = expression.staticElement; |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2645 | 2645 |
2646 @override | 2646 @override |
2647 Element get staticElement => null; | 2647 Element get staticElement => null; |
2648 | 2648 |
2649 @override | 2649 @override |
2650 dynamic/*=E*/ accept/*<E>*/(AstVisitor/*<E>*/ visitor) => null; | 2650 dynamic/*=E*/ accept/*<E>*/(AstVisitor/*<E>*/ visitor) => null; |
2651 | 2651 |
2652 @override | 2652 @override |
2653 void visitChildren(AstVisitor visitor) {} | 2653 void visitChildren(AstVisitor visitor) {} |
2654 } | 2654 } |
OLD | NEW |