| 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 2532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2543 TypeSystem ts = linker.typeSystem; | 2543 TypeSystem ts = linker.typeSystem; |
| 2544 if (rawMethodType != null) { | 2544 if (rawMethodType != null) { |
| 2545 if (rawMethodType.typeFormals.isNotEmpty && typeArguments.isNotEmpty) { | 2545 if (rawMethodType.typeFormals.isNotEmpty && typeArguments.isNotEmpty) { |
| 2546 Element methodElement = rawMethodType.element; | 2546 Element methodElement = rawMethodType.element; |
| 2547 if (methodElement is TypeParameterizedElement && | 2547 if (methodElement is TypeParameterizedElement && |
| 2548 methodElement.typeParameters.length == typeArguments.length) { | 2548 methodElement.typeParameters.length == typeArguments.length) { |
| 2549 return rawMethodType.instantiate(typeArguments); | 2549 return rawMethodType.instantiate(typeArguments); |
| 2550 } | 2550 } |
| 2551 } else if (rawMethodType.typeFormals.isNotEmpty && | 2551 } else if (rawMethodType.typeFormals.isNotEmpty && |
| 2552 ts is StrongTypeSystemImpl) { | 2552 ts is StrongTypeSystemImpl) { |
| 2553 List<DartType> paramTypes = <DartType>[]; | 2553 List<ParameterElement> params = <ParameterElement>[]; |
| 2554 List<DartType> argTypes = <DartType>[]; | 2554 List<DartType> argTypes = <DartType>[]; |
| 2555 // Add positional parameter and argument types. | 2555 // Add positional parameter and argument types. |
| 2556 for (int i = 0; i < numPositional; i++) { | 2556 for (int i = 0; i < numPositional; i++) { |
| 2557 ParameterElement parameter = rawMethodType.parameters[i]; | 2557 ParameterElement parameter = rawMethodType.parameters[i]; |
| 2558 if (parameter != null) { | 2558 if (parameter != null) { |
| 2559 paramTypes.add(parameter.type); | 2559 params.add(parameter); |
| 2560 argTypes.add(positionalArgTypes[i]); | 2560 argTypes.add(positionalArgTypes[i]); |
| 2561 } | 2561 } |
| 2562 } | 2562 } |
| 2563 // Prepare named argument types map. | 2563 // Prepare named argument types map. |
| 2564 Map<String, DartType> namedArgTypes = <String, DartType>{}; | 2564 Map<String, DartType> namedArgTypes = <String, DartType>{}; |
| 2565 for (int i = 0; i < numNamed; i++) { | 2565 for (int i = 0; i < numNamed; i++) { |
| 2566 String name = namedArgNames[i]; | 2566 String name = namedArgNames[i]; |
| 2567 DartType type = namedArgTypeList[i]; | 2567 DartType type = namedArgTypeList[i]; |
| 2568 namedArgTypes[name] = type; | 2568 namedArgTypes[name] = type; |
| 2569 } | 2569 } |
| 2570 // Add named parameter and argument types. | 2570 // Add named parameter and argument types. |
| 2571 Map<String, DartType> namedParameterTypes = | 2571 Map<String, ParameterElement> namedParameters = new Map.fromIterable( |
| 2572 rawMethodType.namedParameterTypes; | 2572 rawMethodType.parameters |
| 2573 .where((p) => p.parameterKind == ParameterKind.NAMED), |
| 2574 key: (p) => p.name); |
| 2573 namedArgTypes.forEach((String name, DartType argType) { | 2575 namedArgTypes.forEach((String name, DartType argType) { |
| 2574 DartType parameterType = namedParameterTypes[name]; | 2576 ParameterElement parameter = namedParameters[name]; |
| 2575 if (parameterType != null) { | 2577 if (parameter != null) { |
| 2576 paramTypes.add(parameterType); | 2578 params.add(parameter); |
| 2577 argTypes.add(argType); | 2579 argTypes.add(argType); |
| 2578 } | 2580 } |
| 2579 }); | 2581 }); |
| 2580 // Perform inference. | 2582 // Perform inference. |
| 2581 FunctionType inferred = ts.inferGenericFunctionCall(rawMethodType, | 2583 FunctionType inferred = ts.inferGenericFunctionOrType( |
| 2582 paramTypes, argTypes, rawMethodType.returnType, null); | 2584 rawMethodType, params, argTypes, rawMethodType.returnType, null); |
| 2583 return inferred; | 2585 return inferred; |
| 2584 } | 2586 } |
| 2585 } | 2587 } |
| 2586 // Not a generic function type, use the raw type. | 2588 // Not a generic function type, use the raw type. |
| 2587 return rawMethodType; | 2589 return rawMethodType; |
| 2588 } | 2590 } |
| 2589 | 2591 |
| 2590 DartType _leastUpperBound(DartType s, DartType t) { | 2592 DartType _leastUpperBound(DartType s, DartType t) { |
| 2591 return linker.typeSystem.getLeastUpperBound(s, t); | 2593 return linker.typeSystem.getLeastUpperBound(s, t); |
| 2592 } | 2594 } |
| (...skipping 2409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5002 * there are no type parameters in scope. | 5004 * there are no type parameters in scope. |
| 5003 */ | 5005 */ |
| 5004 TypeParameterizedElementMixin get _typeParameterContext; | 5006 TypeParameterizedElementMixin get _typeParameterContext; |
| 5005 | 5007 |
| 5006 @override | 5008 @override |
| 5007 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 5009 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 5008 | 5010 |
| 5009 @override | 5011 @override |
| 5010 String toString() => '$enclosingElement.$name'; | 5012 String toString() => '$enclosingElement.$name'; |
| 5011 } | 5013 } |
| OLD | NEW |