| 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; | 5 library engine.resolver; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import '../task/strong/info.dart' show InferredType, StaticInfo; | 9 import '../task/strong/info.dart' show InferredType, StaticInfo; |
| 10 import '../task/strong/rules.dart' show TypeRules; | 10 import '../task/strong/rules.dart' show TypeRules; |
| (...skipping 11697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11708 new List<Map<VariableElement, DartType>>(); | 11708 new List<Map<VariableElement, DartType>>(); |
| 11709 perBranchOverrides.add(thenOverrides); | 11709 perBranchOverrides.add(thenOverrides); |
| 11710 perBranchOverrides.add(elseOverrides); | 11710 perBranchOverrides.add(elseOverrides); |
| 11711 _overrideManager.mergeOverrides(perBranchOverrides); | 11711 _overrideManager.mergeOverrides(perBranchOverrides); |
| 11712 } | 11712 } |
| 11713 return null; | 11713 return null; |
| 11714 } | 11714 } |
| 11715 | 11715 |
| 11716 @override | 11716 @override |
| 11717 Object visitInstanceCreationExpression(InstanceCreationExpression node) { | 11717 Object visitInstanceCreationExpression(InstanceCreationExpression node) { |
| 11718 DartType contextType = InferenceContext.getType(node); | 11718 TypeName classTypeName = node.constructorName.type; |
| 11719 if (contextType is InterfaceType && | 11719 if (classTypeName.typeArguments == null) { |
| 11720 contextType.typeArguments != null && | 11720 DartType contextType = InferenceContext.getType(node); |
| 11721 contextType.typeArguments.length > 0) { | 11721 if (contextType is InterfaceType && |
| 11722 TypeName classTypeName = node.constructorName.type; | 11722 contextType.typeArguments != null && |
| 11723 if (classTypeName.typeArguments == null) { | 11723 contextType.typeArguments.length > 0) { |
| 11724 List<DartType> targs = | 11724 List<DartType> targs = |
| 11725 inferenceContext.matchTypes(classTypeName.type, contextType); | 11725 inferenceContext.matchTypes(classTypeName.type, contextType); |
| 11726 if (targs != null && targs.any((t) => !t.isDynamic)) { | 11726 if (targs != null && targs.any((t) => !t.isDynamic)) { |
| 11727 ClassElement classElement = classTypeName.type.element; | 11727 ClassElement classElement = classTypeName.type.element; |
| 11728 InterfaceType rawType = classElement.type; | 11728 InterfaceType rawType = classElement.type; |
| 11729 InterfaceType fullType = | 11729 InterfaceType fullType = |
| 11730 rawType.substitute2(targs, rawType.typeArguments); | 11730 rawType.substitute2(targs, rawType.typeArguments); |
| 11731 // The element resolver uses the type on the constructor name, so | 11731 // The element resolver uses the type on the constructor name, so |
| 11732 // infer it first | 11732 // infer it first |
| 11733 typeAnalyzer.inferConstructorName(node.constructorName, fullType); | 11733 typeAnalyzer.inferConstructorName(node.constructorName, fullType); |
| 11734 safelyVisit(node.constructorName); | |
| 11735 ConstructorElement invokedConstructor = | |
| 11736 node.constructorName.staticElement; | |
| 11737 FunctionType rawConstructorType = invokedConstructor.type; | |
| 11738 FunctionType constructorType = rawConstructorType.substitute2( | |
| 11739 targs, rawConstructorType.typeArguments); | |
| 11740 InferenceContext.setType(node.argumentList, constructorType); | |
| 11741 safelyVisit(node.argumentList); | |
| 11742 InferenceContext.setType(node, fullType); | |
| 11743 node.accept(elementResolver); | |
| 11744 node.accept(typeAnalyzer); | |
| 11745 return null; | |
| 11746 } | 11734 } |
| 11747 } else { | |
| 11748 InferenceContext.clearType(node); | |
| 11749 } | 11735 } |
| 11750 } | 11736 } |
| 11751 super.visitInstanceCreationExpression(node); | 11737 safelyVisit(node.constructorName); |
| 11738 FunctionType constructorType = node.constructorName.staticElement?.type; |
| 11739 if (constructorType != null) { |
| 11740 InferenceContext.setType(node.argumentList, constructorType); |
| 11741 } |
| 11742 safelyVisit(node.argumentList); |
| 11743 node.accept(elementResolver); |
| 11744 node.accept(typeAnalyzer); |
| 11752 return null; | 11745 return null; |
| 11753 } | 11746 } |
| 11754 | 11747 |
| 11755 @override | 11748 @override |
| 11756 Object visitLabel(Label node) => null; | 11749 Object visitLabel(Label node) => null; |
| 11757 | 11750 |
| 11758 @override | 11751 @override |
| 11759 Object visitLibraryIdentifier(LibraryIdentifier node) => null; | 11752 Object visitLibraryIdentifier(LibraryIdentifier node) => null; |
| 11760 | 11753 |
| 11761 @override | 11754 @override |
| (...skipping 4315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16077 nonFields.add(node); | 16070 nonFields.add(node); |
| 16078 return null; | 16071 return null; |
| 16079 } | 16072 } |
| 16080 | 16073 |
| 16081 @override | 16074 @override |
| 16082 Object visitNode(AstNode node) => node.accept(TypeResolverVisitor_this); | 16075 Object visitNode(AstNode node) => node.accept(TypeResolverVisitor_this); |
| 16083 | 16076 |
| 16084 @override | 16077 @override |
| 16085 Object visitWithClause(WithClause node) => null; | 16078 Object visitWithClause(WithClause node) => null; |
| 16086 } | 16079 } |
| OLD | NEW |