| Index: pkg/analyzer/lib/src/generated/static_type_analyzer.dart
|
| diff --git a/pkg/analyzer/lib/src/generated/static_type_analyzer.dart b/pkg/analyzer/lib/src/generated/static_type_analyzer.dart
|
| index 99a51ce11e396ed8769f890b92003b4000a95eaa..7b461df669cdc6f24e8fba46f306926a26b760f5 100644
|
| --- a/pkg/analyzer/lib/src/generated/static_type_analyzer.dart
|
| +++ b/pkg/analyzer/lib/src/generated/static_type_analyzer.dart
|
| @@ -175,6 +175,34 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<Object> {
|
| }
|
|
|
| /**
|
| + * The Dart Language Specification, 16.29 (Await Expressions):
|
| + *
|
| + * Let flatten(T) = flatten(S) if T = Future<S>, and T otherwise. The
|
| + * static type of [the expression "await e"] is flatten(T) where T is the
|
| + * static type of e.
|
| + */
|
| + @override
|
| + Object visitAwaitExpression(AwaitExpression node) {
|
| + DartType staticExpressionType = _getStaticType(node.expression);
|
| + if (staticExpressionType == null) {
|
| + // TODO(brianwilkerson) Determine whether this can still happen.
|
| + staticExpressionType = _dynamicType;
|
| + }
|
| + DartType staticType = flattenFutures(_typeProvider, staticExpressionType);
|
| + _recordStaticType(node, staticType);
|
| + DartType propagatedExpressionType = node.expression.propagatedType;
|
| + if (propagatedExpressionType != null) {
|
| + DartType propagatedType =
|
| + flattenFutures(_typeProvider, propagatedExpressionType);
|
| + if (propagatedType != null &&
|
| + propagatedType.isMoreSpecificThan(staticType)) {
|
| + _recordPropagatedType(node, propagatedType);
|
| + }
|
| + }
|
| + return null;
|
| + }
|
| +
|
| + /**
|
| * The Dart Language Specification, 12.20: <blockquote>The static type of a logical boolean
|
| * expression is `bool`.</blockquote>
|
| *
|
| @@ -1772,6 +1800,19 @@ class StaticTypeAnalyzer extends SimpleAstVisitor<Object> {
|
| }
|
|
|
| /**
|
| + * Implements the function "flatten" defined in the spec: "Let flatten(T) =
|
| + * flatten(S) if T = Future<S>, and T otherwise."
|
| + */
|
| + static DartType flattenFutures(TypeProvider typeProvider, DartType type) {
|
| + if (type is InterfaceType &&
|
| + type.element == typeProvider.futureType.element &&
|
| + type.typeArguments.length > 0) {
|
| + return flattenFutures(typeProvider, type.typeArguments[0]);
|
| + }
|
| + return type;
|
| + }
|
| +
|
| + /**
|
| * Create a table mapping HTML tag names to the names of the classes (in 'dart:html') that
|
| * implement those tags.
|
| *
|
|
|