| 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 fa82560e055276642182e1a99c6336ffe21b0717..2b09908338aa780f33200fc1b74ee0dd4c912fb1 100644
|
| --- a/pkg/analyzer/lib/src/generated/static_type_analyzer.dart
|
| +++ b/pkg/analyzer/lib/src/generated/static_type_analyzer.dart
|
| @@ -518,7 +518,13 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<Object> {
|
| // * BlockFunctionBody, if we inferred a type from yield/return.
|
| // * we also normalize bottom to dynamic here.
|
| if (_strongMode && (computedType.isBottom || computedType.isDynamic)) {
|
| - computedType = InferenceContext.getType(body) ?? _dynamicType;
|
| + DartType contextType = InferenceContext.getContext(body);
|
| + if (contextType is FutureUnionType) {
|
| + // TODO(jmesserly): can we do something better here?
|
| + computedType = body.isAsynchronous ? contextType.type : _dynamicType;
|
| + } else {
|
| + computedType = contextType ?? _dynamicType;
|
| + }
|
| recordInference = !computedType.isDynamic;
|
| }
|
|
|
| @@ -1983,8 +1989,17 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<Object> {
|
| }
|
| }
|
|
|
| - return ts.inferGenericFunctionCall(_typeProvider, fnType, paramTypes,
|
| - argTypes, InferenceContext.getType(node));
|
| + DartType returnContext = InferenceContext.getContext(node);
|
| + DartType returnType;
|
| + if (returnContext is FutureUnionType) {
|
| + returnType = fnType.returnType.isDartAsyncFuture
|
| + ? returnContext.futureOfType
|
| + : returnContext.type;
|
| + } else {
|
| + returnType = returnContext as DartType;
|
| + }
|
| + return ts.inferGenericFunctionCall(
|
| + _typeProvider, fnType, paramTypes, argTypes, returnType);
|
| }
|
| return null;
|
| }
|
|
|