Skip to content

Commit 1ed7581

Browse files
johnniwinthercommit-bot@chromium.org
authored andcommitted
[cfe] Add test for issue 42540
Closes #42540 Change-Id: I8ea8f03a2682a5b52867787144a2d81c7527ca11 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153340 Reviewed-by: Dmitry Stefantsov <dmitryas@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com>
1 parent 06cb010 commit 1ed7581

8 files changed

+131
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
dynamic getNull() => null;
6+
7+
Future<Object> fn() async {
8+
Object o = await getNull();
9+
return await getNull();
10+
}
11+
12+
main() {}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
library /*isNonNullableByDefault*/;
2+
import self as self;
3+
import "dart:async" as asy;
4+
import "dart:core" as core;
5+
6+
static method getNull() → dynamic
7+
;
8+
static method fn() → asy::Future<core::Object>
9+
;
10+
static method main() → dynamic
11+
;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
library /*isNonNullableByDefault*/;
2+
import self as self;
3+
import "dart:async" as asy;
4+
import "dart:core" as core;
5+
6+
static method getNull() → dynamic
7+
return null;
8+
static method fn() → asy::Future<core::Object> async {
9+
core::Object o = await self::getNull() as{TypeError,ForDynamic,ForNonNullableByDefault} core::Object;
10+
return await self::getNull() as{TypeError,ForDynamic,ForNonNullableByDefault} FutureOr<core::Object>;
11+
}
12+
static method main() → dynamic {}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
library /*isNonNullableByDefault*/;
2+
import self as self;
3+
import "dart:async" as asy;
4+
import "dart:core" as core;
5+
6+
static method getNull() → dynamic
7+
return null;
8+
static method fn() → asy::Future<core::Object> /* originally async */ {
9+
final asy::_AsyncAwaitCompleter<core::Object> :async_completer = new asy::_AsyncAwaitCompleter::•<core::Object>();
10+
FutureOr<core::Object>? :return_value;
11+
dynamic :async_stack_trace;
12+
(dynamic) → dynamic :async_op_then;
13+
(core::Object, core::StackTrace) → dynamic :async_op_error;
14+
core::int :await_jump_var = 0;
15+
dynamic :await_ctx_var;
16+
dynamic :saved_try_context_var0;
17+
function :async_op([dynamic :result, dynamic :exception, dynamic :stack_trace]) → dynamic yielding
18+
try {
19+
#L1:
20+
{
21+
[yield] let dynamic #t1 = asy::_awaitHelper(self::getNull(), :async_op_then, :async_op_error, :async_op) in null;
22+
core::Object o = let dynamic #t2 = :result in #t2.==(null) ?{core::Object} #t2 as{TypeError,ForDynamic,ForNonNullableByDefault} core::Object : #t2{core::Object};
23+
[yield] let dynamic #t3 = asy::_awaitHelper(self::getNull(), :async_op_then, :async_op_error, :async_op) in null;
24+
:return_value = let dynamic #t4 = :result in #t4.==(null) ?{FutureOr<core::Object>} #t4 as{TypeError,ForDynamic,ForNonNullableByDefault} FutureOr<core::Object> : #t4{FutureOr<core::Object>};
25+
break #L1;
26+
}
27+
asy::_completeOnAsyncReturn(:async_completer, :return_value);
28+
return;
29+
}
30+
on dynamic catch(dynamic exception, core::StackTrace stack_trace) {
31+
:async_completer.{asy::Completer::completeError}(exception, stack_trace);
32+
}
33+
:async_stack_trace = asy::_asyncStackTraceHelper(:async_op);
34+
:async_op_then = asy::_asyncThenWrapperHelper(:async_op);
35+
:async_op_error = asy::_asyncErrorWrapperHelper(:async_op);
36+
:async_completer.{asy::_AsyncAwaitCompleter::start}(:async_op);
37+
return :async_completer.{asy::Completer::future};
38+
}
39+
static method main() → dynamic {}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dynamic getNull() => null;
2+
Future<Object> fn() async {}
3+
main() {}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Future<Object> fn() async {}
2+
dynamic getNull() => null;
3+
main() {}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
library /*isNonNullableByDefault*/;
2+
import self as self;
3+
import "dart:async" as asy;
4+
import "dart:core" as core;
5+
6+
static method getNull() → dynamic
7+
return null;
8+
static method fn() → asy::Future<core::Object> async {
9+
core::Object o = await self::getNull() as{TypeError,ForDynamic,ForNonNullableByDefault} core::Object;
10+
return await self::getNull() as{TypeError,ForDynamic,ForNonNullableByDefault} FutureOr<core::Object>;
11+
}
12+
static method main() → dynamic {}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
library /*isNonNullableByDefault*/;
2+
import self as self;
3+
import "dart:async" as asy;
4+
import "dart:core" as core;
5+
6+
static method getNull() → dynamic
7+
return null;
8+
static method fn() → asy::Future<core::Object> /* originally async */ {
9+
final asy::_AsyncAwaitCompleter<core::Object> :async_completer = new asy::_AsyncAwaitCompleter::•<core::Object>();
10+
FutureOr<core::Object>? :return_value;
11+
dynamic :async_stack_trace;
12+
(dynamic) → dynamic :async_op_then;
13+
(core::Object, core::StackTrace) → dynamic :async_op_error;
14+
core::int :await_jump_var = 0;
15+
dynamic :await_ctx_var;
16+
dynamic :saved_try_context_var0;
17+
function :async_op([dynamic :result, dynamic :exception, dynamic :stack_trace]) → dynamic yielding
18+
try {
19+
#L1:
20+
{
21+
[yield] let dynamic #t1 = asy::_awaitHelper(self::getNull(), :async_op_then, :async_op_error, :async_op) in null;
22+
core::Object o = :result;
23+
[yield] let dynamic #t2 = asy::_awaitHelper(self::getNull(), :async_op_then, :async_op_error, :async_op) in null;
24+
:return_value = :result;
25+
break #L1;
26+
}
27+
asy::_completeOnAsyncReturn(:async_completer, :return_value);
28+
return;
29+
}
30+
on dynamic catch(dynamic exception, core::StackTrace stack_trace) {
31+
:async_completer.{asy::Completer::completeError}(exception, stack_trace);
32+
}
33+
:async_stack_trace = asy::_asyncStackTraceHelper(:async_op);
34+
:async_op_then = asy::_asyncThenWrapperHelper(:async_op);
35+
:async_op_error = asy::_asyncErrorWrapperHelper(:async_op);
36+
:async_completer.{asy::_AsyncAwaitCompleter::start}(:async_op);
37+
return :async_completer.{asy::Completer::future};
38+
}
39+
static method main() → dynamic {}

0 commit comments

Comments
 (0)