Chromium Code Reviews| Index: pkg/analyzer/lib/src/summary/link.dart |
| diff --git a/pkg/analyzer/lib/src/summary/link.dart b/pkg/analyzer/lib/src/summary/link.dart |
| index 9805659ea59e623b4fccbaf2ecc2b17e128b2f58..cf1f1ecd3a2d84b03ce1ffe4943038bc93eedf9f 100644 |
| --- a/pkg/analyzer/lib/src/summary/link.dart |
| +++ b/pkg/analyzer/lib/src/summary/link.dart |
| @@ -3244,16 +3244,51 @@ class TypeInferenceNode extends Node<TypeInferenceNode> { |
| stack.add(DynamicTypeImpl.instance); |
| break; |
| case UnlinkedConstOperation.invokeMethod: |
| - strPtr++; |
| int numNamed = unlinkedConst.ints[intPtr++]; |
| int numPositional = unlinkedConst.ints[intPtr++]; |
| - // TODO(paulberry): don't just pop the args; use their types |
| - // to infer the type of type arguments. |
| - stack.length -= numNamed + numPositional; |
| - strPtr += numNamed; |
| - stack.removeLast(); |
| - // TODO(paulberry): implement. |
| - stack.add(DynamicTypeImpl.instance); |
| + Map<String, DartType> namedArgTypes = <String, DartType>{}; |
| + List<DartType> namedArgTypeList = popList(numNamed); |
| + for (int i = 0; i < numNamed; i++) { |
| + String name = unlinkedConst.strings[strPtr++]; |
| + DartType type = namedArgTypeList[i]; |
| + namedArgTypes[name] = type; |
| + } |
| + List<DartType> positionalArgTypes = popList(numPositional); |
| + String methodName = unlinkedConst.strings[strPtr++]; |
| + DartType target = stack.removeLast(); |
| + stack.add(() { |
| + if (target is InterfaceType) { |
| + MethodElement method = |
| + target.lookUpMethod(methodName, libraryElement); |
| + DartType rawMethodType = method?.type; |
| + TypeSystem ts = linker.typeSystem; |
| + if (rawMethodType is FunctionType && |
| + rawMethodType.typeFormals.isNotEmpty && |
|
Paul Berry
2016/04/09 12:04:29
This means we won't handle non-generic cases. Sug
scheglov
2016/04/10 01:29:21
Thank you, fixed.
|
| + ts is StrongTypeSystemImpl) { |
| + List<DartType> paramTypes = <DartType>[]; |
| + List<DartType> argTypes = <DartType>[]; |
| + for (int i = 0, length = numPositional; i < length; i++) { |
| + ParameterElement parameter = rawMethodType.parameters[i]; |
| + if (parameter != null) { |
| + paramTypes.add(parameter.type); |
| + argTypes.add(positionalArgTypes[i]); |
| + } |
| + } |
| + Map<String, DartType> namedParameterTypes = rawMethodType.namedParameterTypes; |
| + namedArgTypes.forEach((String name, DartType argType) { |
| + DartType parameterType = namedParameterTypes[name]; |
| + if (parameterType != null) { |
| + paramTypes.add(parameterType); |
| + argTypes.add(argType); |
| + } |
| + }); |
| + FunctionType inferred = ts.inferGenericFunctionCall( |
| + typeProvider, rawMethodType, paramTypes, argTypes, null); |
| + return inferred.returnType; |
| + } |
| + } |
| + return DynamicTypeImpl.instance; |
| + }()); |
| break; |
| case UnlinkedConstOperation.cascadeSectionBegin: |
| stack.add(stack.last); |