| 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/visitor.dart'; | 10 import 'package:analyzer/dart/ast/visitor.dart'; |
| (...skipping 2407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2418 element = _lookUpMethod(null, enclosingType, identifier.name); | 2418 element = _lookUpMethod(null, enclosingType, identifier.name); |
| 2419 } | 2419 } |
| 2420 } | 2420 } |
| 2421 return element; | 2421 return element; |
| 2422 } | 2422 } |
| 2423 | 2423 |
| 2424 /** | 2424 /** |
| 2425 * If the given [type] is a type parameter, resolve it to the type that should | 2425 * If the given [type] is a type parameter, resolve it to the type that should |
| 2426 * be used when looking up members. Otherwise, return the original type. | 2426 * be used when looking up members. Otherwise, return the original type. |
| 2427 */ | 2427 */ |
| 2428 DartType _resolveTypeParameter(DartType type) { | 2428 DartType _resolveTypeParameter(DartType type) => |
| 2429 if (type is TypeParameterType) { | 2429 type?.resolveToBound(_resolver.typeProvider.objectType); |
| 2430 DartType bound = type.element.bound; | |
| 2431 if (bound == null) { | |
| 2432 return _resolver.typeProvider.objectType; | |
| 2433 } | |
| 2434 return bound; | |
| 2435 } | |
| 2436 return type; | |
| 2437 } | |
| 2438 | 2430 |
| 2439 /** | 2431 /** |
| 2440 * Return `true` if we should report an error as a result of looking up a | 2432 * Return `true` if we should report an error as a result of looking up a |
| 2441 * [member] in the given [type] and not finding any member. | 2433 * [member] in the given [type] and not finding any member. |
| 2442 */ | 2434 */ |
| 2443 bool _shouldReportMissingMember(DartType type, Element member) { | 2435 bool _shouldReportMissingMember(DartType type, Element member) { |
| 2444 if (member != null || type == null || type.isDynamic || type.isBottom) { | 2436 return member == null && type != null && !type.isDynamic && !type.isBottom; |
| 2445 return false; | |
| 2446 } | |
| 2447 return true; | |
| 2448 } | 2437 } |
| 2449 | 2438 |
| 2450 /** | 2439 /** |
| 2451 * Checks whether the given [expression] is a reference to a class. If it is | 2440 * Checks whether the given [expression] is a reference to a class. If it is |
| 2452 * then the element representing the class is returned, otherwise `null` is | 2441 * then the element representing the class is returned, otherwise `null` is |
| 2453 * returned. | 2442 * returned. |
| 2454 */ | 2443 */ |
| 2455 static ClassElementImpl getTypeReference(Expression expression) { | 2444 static ClassElementImpl getTypeReference(Expression expression) { |
| 2456 if (expression is Identifier) { | 2445 if (expression is Identifier) { |
| 2457 Element staticElement = expression.staticElement; | 2446 Element staticElement = expression.staticElement; |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2594 | 2583 |
| 2595 @override | 2584 @override |
| 2596 Element get staticElement => null; | 2585 Element get staticElement => null; |
| 2597 | 2586 |
| 2598 @override | 2587 @override |
| 2599 accept(AstVisitor visitor) => null; | 2588 accept(AstVisitor visitor) => null; |
| 2600 | 2589 |
| 2601 @override | 2590 @override |
| 2602 void visitChildren(AstVisitor visitor) {} | 2591 void visitChildren(AstVisitor visitor) {} |
| 2603 } | 2592 } |
| OLD | NEW |