[dart2wasm] Fix awaiting non-future values

New passing tests:

- co19/Language/Statements/For/Asynchronous_For_in/execution_A05_t05
- language/async/await_test/02
- language/async/await_test/03
- language/async/await_test/none
- language/await/nonfuture_test
- language/await/started_immediately_test

Change-Id: I5d5e13f846aa2415abb9788ef341b1d86170937c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286921
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
This commit is contained in:
Ömer Sinan Ağacan
2023-03-08 14:53:40 +00:00
committed by Commit Queue
parent 0ad9f2ec66
commit fa90dcc640
+3 -1
View File
@@ -95,7 +95,9 @@ Object? _awaitHelper(Object? operand, WasmExternRef? stack) {
// ensure that the zone will be restored in the event of an exception by
// restoring the original zone before we throw the exception.
_Zone current = Zone._current;
if (operand is! Future) return operand;
if (operand is! Future) {
operand = Future.value(operand);
}
Object? result = _futurePromise(stack, operand);
Zone._leave(current);
if (result is _FutureError) {