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

Unified Diff: pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart

Issue 2898373004: Use FutureOr as the return context in async closures. (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
diff --git a/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart b/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
index dabcec49e5cf5c1aa1b2e19c045576747955e250..544a8aa9ffcc286ad2eed97aef87c173ef475b61 100644
--- a/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
+++ b/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
@@ -59,9 +59,9 @@ class ClosureContext {
returnContext, inferrer.coreTypes.iterableClass);
}
} else if (isAsync) {
- // TODO(paulberry): do we have to handle FutureOr<> here?
- returnContext = inferrer.getTypeArgumentOf(
- returnContext, inferrer.coreTypes.futureClass);
+ returnContext = inferrer.wrapType(
+ inferrer.typeSchemaEnvironment.flattenFutures(returnContext),
+ inferrer.coreTypes.futureOrClass);
}
return new ClosureContext._(isAsync, isGenerator, returnContext);
}
@@ -416,7 +416,7 @@ abstract class TypeInferrerImpl extends TypeInferrer {
void inferStatement(Statement statement);
DartType wrapFutureType(DartType type) {
- var typeWithoutFutureOr = type;
+ var typeWithoutFutureOr = type ?? const DynamicType();
if (type is InterfaceType &&
identical(type.classNode, coreTypes.futureOrClass)) {
typeWithoutFutureOr = type.typeArguments[0];
@@ -426,7 +426,7 @@ abstract class TypeInferrerImpl extends TypeInferrer {
}
DartType wrapType(DartType type, Class class_) {
- return new InterfaceType(class_, <DartType>[type]);
+ return new InterfaceType(class_, <DartType>[type ?? const DynamicType()]);
}
void _forEachArgument(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698