From fa90dcc640bbd4d5d8ade433ab5f575c865278ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Wed, 8 Mar 2023 14:53:40 +0000 Subject: [PATCH] [dart2wasm] Fix awaiting non-future values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Commit-Queue: Ömer Ağacan --- sdk/lib/_internal/wasm/lib/async_patch.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sdk/lib/_internal/wasm/lib/async_patch.dart b/sdk/lib/_internal/wasm/lib/async_patch.dart index baf3b2b7805..59924186893 100644 --- a/sdk/lib/_internal/wasm/lib/async_patch.dart +++ b/sdk/lib/_internal/wasm/lib/async_patch.dart @@ -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) {