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

Unified Diff: pkg/compiler/lib/src/typechecker.dart

Issue 886833005: Fix await parsing. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added comment Created 5 years, 11 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 | « pkg/compiler/lib/src/scanner/parser.dart ('k') | tests/compiler/dart2js/metadata_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/typechecker.dart
diff --git a/pkg/compiler/lib/src/typechecker.dart b/pkg/compiler/lib/src/typechecker.dart
index 26272a918483b0cec84ffd100ce6a4a1c5d6befb..f338269b29226c612117c80bda1641c55f41f0c8 100644
--- a/pkg/compiler/lib/src/typechecker.dart
+++ b/pkg/compiler/lib/src/typechecker.dart
@@ -1601,17 +1601,28 @@ class TypeCheckerVisitor extends Visitor<DartType> {
return const DynamicType();
}
- DartType visitAwait(Await node) {
- DartType expressionType = analyze(node.expression);
- DartType resultType = expressionType;
- if (expressionType is InterfaceType) {
- InterfaceType futureType =
- expressionType.asInstanceOf(compiler.futureClass);
+ /// Flatten [type] by recursively removing enclosing `Future` annotations.
+ ///
+ /// For instance:
+ /// flatten(T) = T
+ /// flatten(Future<T>) = T
+ /// flatten(Future<Future<T>>) = T
+ ///
+ /// This method is used in the static typing of await and type checking of
+ /// return.
+ DartType flatten(DartType type) {
+ if (type is InterfaceType) {
+ InterfaceType futureType = type.asInstanceOf(compiler.futureClass);
if (futureType != null) {
- resultType = futureType.typeArguments.first;
+ return flatten(futureType.typeArguments.first);
}
}
- return resultType;
+ return type;
+ }
+
+ DartType visitAwait(Await node) {
+ DartType expressionType = analyze(node.expression);
+ return flatten(expressionType);
}
DartType visitYield(Yield node) {
« no previous file with comments | « pkg/compiler/lib/src/scanner/parser.dart ('k') | tests/compiler/dart2js/metadata_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698