| Index: pkg/analyzer/lib/src/generated/static_type_analyzer.dart
|
| diff --git a/pkg/analyzer/lib/src/generated/static_type_analyzer.dart b/pkg/analyzer/lib/src/generated/static_type_analyzer.dart
|
| index b3484a9669f10f2a400eea6da6415c7340da9d7b..764da92450a1689c129064a76df6567b0c754137 100644
|
| --- a/pkg/analyzer/lib/src/generated/static_type_analyzer.dart
|
| +++ b/pkg/analyzer/lib/src/generated/static_type_analyzer.dart
|
| @@ -1915,6 +1915,9 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<Object> {
|
| }
|
| }
|
|
|
| + bool _isSubtypeOfFuture(DartType type) =>
|
| + _typeSystem.isSubtypeOf(type, _typeProvider.futureDynamicType);
|
| +
|
| /**
|
| * Given a possibly generic invocation or instance creation, such as
|
| * `o.m(args)` or `(f)(args)` or `new T(args)` try to infer the instantiated
|
| @@ -1947,7 +1950,7 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<Object> {
|
| DartType returnContext = InferenceContext.getContext(node);
|
| DartType returnType;
|
| if (returnContext is FutureUnionType) {
|
| - returnType = fnType.returnType.isDartAsyncFuture
|
| + returnType = _isSubtypeOfFuture(fnType.returnType)
|
| ? returnContext.futureOfType
|
| : returnContext.type;
|
| } else {
|
| @@ -1974,7 +1977,7 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<Object> {
|
| // S or Future<S> in a conditional.
|
| if (!argReturnType.isObject && !argReturnType.isDynamic) {
|
| DartType paramReturnType = fnType.typeFormals[0].type;
|
| - if (argReturnType.isDartAsyncFuture) {
|
| + if (_isSubtypeOfFuture(argReturnType)) {
|
| // Given an argument of (T) -> Future<S>, instantiate with <S>
|
| paramReturnType =
|
| _typeProvider.futureType.instantiate([paramReturnType]);
|
| @@ -1986,13 +1989,11 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<Object> {
|
| ..shareParameters(firstParamType.parameters)
|
| ..returnType = paramReturnType;
|
| function.type = new FunctionTypeImpl(function);
|
| -
|
| // Use this as the expected 1st parameter type.
|
| paramTypes[0] = function.type;
|
| }
|
| }
|
| }
|
| -
|
| return ts.inferGenericFunctionCall(
|
| _typeProvider, fnType, paramTypes, argTypes, returnType);
|
| }
|
| @@ -2016,6 +2017,13 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<Object> {
|
| return;
|
| }
|
|
|
| + // TODO(leafp): Currently, we may re-infer types here, since we
|
| + // sometimes resolve multiple times. We should really check that we
|
| + // have not already inferred something. However, the obvious ways to
|
| + // check this don't work, since we class may have been instantiated
|
| + // to bounds in an earlier phase, and we *do* want to do inference
|
| + // in that case.
|
| +
|
| // Get back to the uninstantiated generic constructor.
|
| // TODO(jmesserly): should we store this earlier in resolution?
|
| // Or look it up, instead of jumping backwards through the Member?
|
| @@ -2076,7 +2084,6 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<Object> {
|
| }
|
|
|
| computedType = _computeReturnTypeOfFunction(body, computedType);
|
| -
|
| functionElement.returnType = computedType;
|
| _recordPropagatedTypeOfFunction(functionElement, node.body);
|
| _recordStaticType(node, functionElement.type);
|
|
|