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.resolver; | 5 library analyzer.src.generated.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/token.dart'; | 10 import 'package:analyzer/dart/ast/token.dart'; |
(...skipping 6705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6716 } | 6716 } |
6717 | 6717 |
6718 @override | 6718 @override |
6719 Object visitInstanceCreationExpression(InstanceCreationExpression node) { | 6719 Object visitInstanceCreationExpression(InstanceCreationExpression node) { |
6720 TypeName classTypeName = node.constructorName.type; | 6720 TypeName classTypeName = node.constructorName.type; |
6721 if (classTypeName.typeArguments == null) { | 6721 if (classTypeName.typeArguments == null) { |
6722 DartType contextType = InferenceContext.getType(node); | 6722 DartType contextType = InferenceContext.getType(node); |
6723 if (contextType is InterfaceType && | 6723 if (contextType is InterfaceType && |
6724 contextType.typeArguments != null && | 6724 contextType.typeArguments != null && |
6725 contextType.typeArguments.length > 0) { | 6725 contextType.typeArguments.length > 0) { |
| 6726 // TODO(jmesserly): for generic methods we use the |
| 6727 // StrongTypeSystemImpl.inferGenericFunctionCall, which appears to |
| 6728 // be a tad more powerful than matchTypes. |
| 6729 // |
| 6730 // For example it can infer this case: |
| 6731 // |
| 6732 // class E<S, T> extends A<C<S>, T> { ... } |
| 6733 // A<C<int>, String> a0 = /*infer<int, String>*/new E("hello"); |
| 6734 // |
| 6735 // See _inferArgumentTypesFromContext in this file for use of it. |
6726 List<DartType> targs = | 6736 List<DartType> targs = |
6727 inferenceContext.matchTypes(classTypeName.type, contextType); | 6737 inferenceContext.matchTypes(classTypeName.type, contextType); |
6728 if (targs != null && targs.any((t) => !t.isDynamic)) { | 6738 if (targs != null && targs.any((t) => !t.isDynamic)) { |
6729 ClassElement classElement = classTypeName.type.element; | 6739 ClassElement classElement = classTypeName.type.element; |
6730 InterfaceType rawType = classElement.type; | 6740 InterfaceType rawType = classElement.type; |
6731 InterfaceType fullType = | 6741 InterfaceType fullType = |
6732 rawType.substitute2(targs, rawType.typeArguments); | 6742 rawType.substitute2(targs, rawType.typeArguments); |
6733 // The element resolver uses the type on the constructor name, so | 6743 // The element resolver uses the type on the constructor name, so |
6734 // infer it first | 6744 // infer it first |
6735 typeAnalyzer.inferConstructorName(node.constructorName, fullType); | 6745 typeAnalyzer.inferConstructorName(node.constructorName, fullType); |
(...skipping 4304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11040 return null; | 11050 return null; |
11041 } | 11051 } |
11042 if (identical(node.staticElement, variable)) { | 11052 if (identical(node.staticElement, variable)) { |
11043 if (node.inSetterContext()) { | 11053 if (node.inSetterContext()) { |
11044 result = true; | 11054 result = true; |
11045 } | 11055 } |
11046 } | 11056 } |
11047 return null; | 11057 return null; |
11048 } | 11058 } |
11049 } | 11059 } |
OLD | NEW |