| Index: pkg/analyzer/lib/src/generated/type_system.dart
|
| diff --git a/pkg/analyzer/lib/src/generated/type_system.dart b/pkg/analyzer/lib/src/generated/type_system.dart
|
| index 19b5be5fdb2120fcfec3753681271abc4210e954..f34e7e67fda6049ce5bf5af7d85e1c24fce63d83 100644
|
| --- a/pkg/analyzer/lib/src/generated/type_system.dart
|
| +++ b/pkg/analyzer/lib/src/generated/type_system.dart
|
| @@ -203,6 +203,23 @@ class StrongTypeSystemImpl extends TypeSystem {
|
| var inferringTypeSystem =
|
| new _StrongInferenceTypeSystem(typeProvider, fnType.typeFormals);
|
|
|
| + // Special case inference for Future.then.
|
| + //
|
| + // We don't have union types, so Future<T>.then<S> is typed to take a
|
| + // callback `T -> S`. However, the lambda might actually return a
|
| + // Future<S>. So we handle that special case here.
|
| + Element element = fnType?.element;
|
| + bool isFutureThen = element is MethodElement &&
|
| + element.name == 'then' &&
|
| + element.enclosingElement.type.isDartAsyncFuture;
|
| + if (isFutureThen &&
|
| + argumentTypes.isNotEmpty &&
|
| + argumentTypes[0] is FunctionType) {
|
| + // Ignore return context. We'll let the onValue function's return type
|
| + // drive inference.
|
| + returnContextType = null;
|
| + }
|
| +
|
| if (returnContextType != null) {
|
| inferringTypeSystem.isSubtypeOf(fnType.returnType, returnContextType);
|
| }
|
|
|