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 9a4a5cf8264fcefb081bae954087bafe0cc52acc..1abf232d518fffbe778f29b558fdeb9853f5e3e3 100644 |
--- a/pkg/analyzer/lib/src/generated/type_system.dart |
+++ b/pkg/analyzer/lib/src/generated/type_system.dart |
@@ -277,6 +277,16 @@ class StrongTypeSystemImpl extends TypeSystem { |
return fnType; |
} |
+ // If we're in a future union context, choose either the Future<T> or the T |
+ // based on the function's return type. |
+ if (returnContextType is FutureUnionType) { |
+ var futureUnion = returnContextType as FutureUnionType; |
+ returnContextType = |
+ isSubtypeOf(fnType.returnType, typeProvider.futureDynamicType) |
+ ? futureUnion.futureOfType |
+ : futureUnion.type; |
+ } |
+ |
// Create a TypeSystem that will allow certain type parameters to be |
// inferred. It will optimistically assume these type parameters can be |
// subtypes (or supertypes) as necessary, and track the constraints that |