| 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 2635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2646 TypeSystem ts = linker.typeSystem; | 2646 TypeSystem ts = linker.typeSystem; |
| 2647 if (rawMethodType != null) { | 2647 if (rawMethodType != null) { |
| 2648 if (rawMethodType.typeFormals.isNotEmpty && typeArguments.isNotEmpty) { | 2648 if (rawMethodType.typeFormals.isNotEmpty && typeArguments.isNotEmpty) { |
| 2649 Element methodElement = rawMethodType.element; | 2649 Element methodElement = rawMethodType.element; |
| 2650 if (methodElement is TypeParameterizedElement && | 2650 if (methodElement is TypeParameterizedElement && |
| 2651 methodElement.typeParameters.length == typeArguments.length) { | 2651 methodElement.typeParameters.length == typeArguments.length) { |
| 2652 return rawMethodType.instantiate(typeArguments); | 2652 return rawMethodType.instantiate(typeArguments); |
| 2653 } | 2653 } |
| 2654 } else if (rawMethodType.typeFormals.isNotEmpty && | 2654 } else if (rawMethodType.typeFormals.isNotEmpty && |
| 2655 ts is StrongTypeSystemImpl) { | 2655 ts is StrongTypeSystemImpl) { |
| 2656 List<DartType> paramTypes = <DartType>[]; | 2656 List<ParameterElement> params = <ParameterElement>[]; |
| 2657 List<DartType> argTypes = <DartType>[]; | 2657 List<DartType> argTypes = <DartType>[]; |
| 2658 // Add positional parameter and argument types. | 2658 // Add positional parameter and argument types. |
| 2659 for (int i = 0; i < numPositional; i++) { | 2659 for (int i = 0; i < numPositional; i++) { |
| 2660 ParameterElement parameter = rawMethodType.parameters[i]; | 2660 ParameterElement parameter = rawMethodType.parameters[i]; |
| 2661 if (parameter != null) { | 2661 if (parameter != null) { |
| 2662 paramTypes.add(parameter.type); | 2662 params.add(parameter); |
| 2663 argTypes.add(positionalArgTypes[i]); | 2663 argTypes.add(positionalArgTypes[i]); |
| 2664 } | 2664 } |
| 2665 } | 2665 } |
| 2666 // Prepare named argument types map. | 2666 // Prepare named argument types map. |
| 2667 Map<String, DartType> namedArgTypes = <String, DartType>{}; | 2667 Map<String, DartType> namedArgTypes = <String, DartType>{}; |
| 2668 for (int i = 0; i < numNamed; i++) { | 2668 for (int i = 0; i < numNamed; i++) { |
| 2669 String name = namedArgNames[i]; | 2669 String name = namedArgNames[i]; |
| 2670 DartType type = namedArgTypeList[i]; | 2670 DartType type = namedArgTypeList[i]; |
| 2671 namedArgTypes[name] = type; | 2671 namedArgTypes[name] = type; |
| 2672 } | 2672 } |
| 2673 // Add named parameter and argument types. | 2673 // Add named parameter and argument types. |
| 2674 Map<String, DartType> namedParameterTypes = | 2674 Map<String, ParameterElement> namedParameters = new Map.fromIterable( |
| 2675 rawMethodType.namedParameterTypes; | 2675 rawMethodType.parameters |
| 2676 .where((p) => p.parameterKind == ParameterKind.NAMED), |
| 2677 key: (p) => p.name); |
| 2676 namedArgTypes.forEach((String name, DartType argType) { | 2678 namedArgTypes.forEach((String name, DartType argType) { |
| 2677 DartType parameterType = namedParameterTypes[name]; | 2679 ParameterElement parameter = namedParameters[name]; |
| 2678 if (parameterType != null) { | 2680 if (parameter != null) { |
| 2679 paramTypes.add(parameterType); | 2681 params.add(parameter); |
| 2680 argTypes.add(argType); | 2682 argTypes.add(argType); |
| 2681 } | 2683 } |
| 2682 }); | 2684 }); |
| 2683 // Perform inference. | 2685 // Perform inference. |
| 2684 FunctionType inferred = ts.inferGenericFunctionCall( | 2686 FunctionType inferred = ts.inferGenericFunctionOrType(typeProvider, |
| 2685 typeProvider, | 2687 rawMethodType, params, argTypes, rawMethodType.returnType, null); |
| 2686 rawMethodType, | |
| 2687 paramTypes, | |
| 2688 argTypes, | |
| 2689 rawMethodType.returnType, | |
| 2690 null); | |
| 2691 return inferred; | 2688 return inferred; |
| 2692 } | 2689 } |
| 2693 } | 2690 } |
| 2694 // Not a generic function type, use the raw type. | 2691 // Not a generic function type, use the raw type. |
| 2695 return rawMethodType; | 2692 return rawMethodType; |
| 2696 } | 2693 } |
| 2697 | 2694 |
| 2698 DartType _leastUpperBound(DartType s, DartType t) { | 2695 DartType _leastUpperBound(DartType s, DartType t) { |
| 2699 return linker.typeSystem.getLeastUpperBound(typeProvider, s, t); | 2696 return linker.typeSystem.getLeastUpperBound(typeProvider, s, t); |
| 2700 } | 2697 } |
| (...skipping 2411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5112 * there are no type parameters in scope. | 5109 * there are no type parameters in scope. |
| 5113 */ | 5110 */ |
| 5114 TypeParameterizedElementMixin get _typeParameterContext; | 5111 TypeParameterizedElementMixin get _typeParameterContext; |
| 5115 | 5112 |
| 5116 @override | 5113 @override |
| 5117 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 5114 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 5118 | 5115 |
| 5119 @override | 5116 @override |
| 5120 String toString() => '$enclosingElement.$name'; | 5117 String toString() => '$enclosingElement.$name'; |
| 5121 } | 5118 } |
| OLD | NEW |