OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 /** | 5 /** |
6 * This library is capable of producing linked summaries from unlinked | 6 * This library is capable of producing linked summaries from unlinked |
7 * ones (or prelinked ones). It functions by building a miniature | 7 * ones (or prelinked ones). It functions by building a miniature |
8 * element model to represent the contents of the summaries, and then | 8 * element model to represent the contents of the summaries, and then |
9 * scanning the element model to gather linked information and adding | 9 * scanning the element model to gather linked information and adding |
10 * it to the summary data structures. | 10 * it to the summary data structures. |
(...skipping 2581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2592 TypeSystem ts = linker.typeSystem; | 2592 TypeSystem ts = linker.typeSystem; |
2593 if (rawMethodType != null) { | 2593 if (rawMethodType != null) { |
2594 if (rawMethodType.typeFormals.isNotEmpty && typeArguments.isNotEmpty) { | 2594 if (rawMethodType.typeFormals.isNotEmpty && typeArguments.isNotEmpty) { |
2595 Element methodElement = rawMethodType.element; | 2595 Element methodElement = rawMethodType.element; |
2596 if (methodElement is TypeParameterizedElement && | 2596 if (methodElement is TypeParameterizedElement && |
2597 methodElement.typeParameters.length == typeArguments.length) { | 2597 methodElement.typeParameters.length == typeArguments.length) { |
2598 return rawMethodType.instantiate(typeArguments); | 2598 return rawMethodType.instantiate(typeArguments); |
2599 } | 2599 } |
2600 } else if (rawMethodType.typeFormals.isNotEmpty && | 2600 } else if (rawMethodType.typeFormals.isNotEmpty && |
2601 ts is StrongTypeSystemImpl) { | 2601 ts is StrongTypeSystemImpl) { |
2602 List<DartType> paramTypes = <DartType>[]; | 2602 List<ParameterElement> params = <ParameterElement>[]; |
2603 List<DartType> argTypes = <DartType>[]; | 2603 List<DartType> argTypes = <DartType>[]; |
2604 // Add positional parameter and argument types. | 2604 // Add positional parameter and argument types. |
2605 for (int i = 0; i < numPositional; i++) { | 2605 for (int i = 0; i < numPositional; i++) { |
2606 ParameterElement parameter = rawMethodType.parameters[i]; | 2606 ParameterElement parameter = rawMethodType.parameters[i]; |
2607 if (parameter != null) { | 2607 if (parameter != null) { |
2608 paramTypes.add(parameter.type); | 2608 params.add(parameter); |
2609 argTypes.add(positionalArgTypes[i]); | 2609 argTypes.add(positionalArgTypes[i]); |
2610 } | 2610 } |
2611 } | 2611 } |
2612 // Prepare named argument types map. | 2612 // Prepare named argument types map. |
2613 Map<String, DartType> namedArgTypes = <String, DartType>{}; | 2613 Map<String, DartType> namedArgTypes = <String, DartType>{}; |
2614 for (int i = 0; i < numNamed; i++) { | 2614 for (int i = 0; i < numNamed; i++) { |
2615 String name = namedArgNames[i]; | 2615 String name = namedArgNames[i]; |
2616 DartType type = namedArgTypeList[i]; | 2616 DartType type = namedArgTypeList[i]; |
2617 namedArgTypes[name] = type; | 2617 namedArgTypes[name] = type; |
2618 } | 2618 } |
2619 // Add named parameter and argument types. | 2619 // Add named parameter and argument types. |
2620 Map<String, DartType> namedParameterTypes = | 2620 Map<String, ParameterElement> namedParameters = new Map.fromIterable( |
2621 rawMethodType.namedParameterTypes; | 2621 rawMethodType.parameters |
| 2622 .where((p) => p.parameterKind == ParameterKind.NAMED), |
| 2623 key: (p) => p.name); |
2622 namedArgTypes.forEach((String name, DartType argType) { | 2624 namedArgTypes.forEach((String name, DartType argType) { |
2623 DartType parameterType = namedParameterTypes[name]; | 2625 ParameterElement parameter = namedParameters[name]; |
2624 if (parameterType != null) { | 2626 if (parameter != null) { |
2625 paramTypes.add(parameterType); | 2627 params.add(parameter); |
2626 argTypes.add(argType); | 2628 argTypes.add(argType); |
2627 } | 2629 } |
2628 }); | 2630 }); |
2629 // Perform inference. | 2631 // Perform inference. |
2630 FunctionType inferred = ts.inferGenericFunctionCall(rawMethodType, | 2632 FunctionType inferred = ts.inferGenericFunctionOrType( |
2631 paramTypes, argTypes, rawMethodType.returnType, null); | 2633 rawMethodType, params, argTypes, null); |
2632 return inferred; | 2634 return inferred; |
2633 } | 2635 } |
2634 } | 2636 } |
2635 // Not a generic function type, use the raw type. | 2637 // Not a generic function type, use the raw type. |
2636 return rawMethodType; | 2638 return rawMethodType; |
2637 } | 2639 } |
2638 | 2640 |
2639 DartType _leastUpperBound(DartType s, DartType t) { | 2641 DartType _leastUpperBound(DartType s, DartType t) { |
2640 return linker.typeSystem.getLeastUpperBound(s, t); | 2642 return linker.typeSystem.getLeastUpperBound(s, t); |
2641 } | 2643 } |
(...skipping 2541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5183 * there are no type parameters in scope. | 5185 * there are no type parameters in scope. |
5184 */ | 5186 */ |
5185 TypeParameterizedElementMixin get _typeParameterContext; | 5187 TypeParameterizedElementMixin get _typeParameterContext; |
5186 | 5188 |
5187 @override | 5189 @override |
5188 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 5190 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
5189 | 5191 |
5190 @override | 5192 @override |
5191 String toString() => '$enclosingElement.$name'; | 5193 String toString() => '$enclosingElement.$name'; |
5192 } | 5194 } |
OLD | NEW |