Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1022)

Unified Diff: pkg/analyzer/lib/src/generated/type_system.dart

Issue 2280463002: fix #27134, future unions in downwards generic method inference (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: format Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
« no previous file with comments | « pkg/analyzer/lib/src/generated/static_type_analyzer.dart ('k') | pkg/analyzer/test/src/task/strong/inferred_type_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698