File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -180,7 +180,13 @@ class GraphBuilder extends GeneralizingAstVisitor<DecoratedType> {
180180
181181 @override
182182 DecoratedType visitAwaitExpression (AwaitExpression node) {
183- throw new UnimplementedError ('TODO(brianwilkerson)' );
183+ var expressionType = node.expression.accept (this );
184+ // TODO(paulberry) Handle subclasses of Future.
185+ if (expressionType.type.isDartAsyncFuture ||
186+ expressionType.type.isDartAsyncFutureOr) {
187+ expressionType = expressionType.typeArguments[0 ];
188+ }
189+ return expressionType;
184190 }
185191
186192 @override
Original file line number Diff line number Diff line change @@ -272,6 +272,40 @@ void f(C c, int i) {
272272 checkExpression ('c.s' ), decoratedTypeAnnotation ('C c' ).node);
273273 }
274274
275+ @failingTest
276+ test_awaitExpression_future_nonNullable () async {
277+ await analyze ('''
278+ Future<void> f() async {
279+ int x = await g();
280+ }
281+ Future<int> g() async => 3;
282+ ''' );
283+
284+ assertNoUpstreamNullability (decoratedTypeAnnotation ('int' ).node);
285+ }
286+
287+ @failingTest
288+ test_awaitExpression_future_nullable () async {
289+ await analyze ('''
290+ Future<void> f() async {
291+ int x = await g();
292+ }
293+ Future<int> g() async => null;
294+ ''' );
295+
296+ assertNoUpstreamNullability (decoratedTypeAnnotation ('int' ).node);
297+ }
298+
299+ test_awaitExpression_nonFuture () async {
300+ await analyze ('''
301+ Future<void> f() async {
302+ int x = await 3;
303+ }
304+ ''' );
305+
306+ assertNoUpstreamNullability (decoratedTypeAnnotation ('int' ).node);
307+ }
308+
275309 test_binaryExpression_add_left_check () async {
276310 await analyze ('''
277311int f(int i, int j) => i + j;
You can’t perform that action at this time.
0 commit comments