| 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) {
|
|
|