From a3e243154ccb1a1ea88f88dd4334f4b28ff0485b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20A=C4=9Facan?= Date: Mon, 14 Apr 2025 09:48:40 -0700 Subject: [PATCH] [dart2wasm] Simplify void JS return value boxing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I875a8e0bc83f2338b74060e871f22a02ef808755 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/422301 Reviewed-by: Nate Biggs Commit-Queue: Ömer Ağacan --- pkg/dart2wasm/lib/js/util.dart | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pkg/dart2wasm/lib/js/util.dart b/pkg/dart2wasm/lib/js/util.dart index 4f67233556c..9471b349c5e 100644 --- a/pkg/dart2wasm/lib/js/util.dart +++ b/pkg/dart2wasm/lib/js/util.dart @@ -285,18 +285,15 @@ class CoreTypesUtil { /// Cast the [invocation] if needed to conform to the expected [returnType]. Expression castInvocationForReturn( Expression invocation, DartType returnType) { - if (returnType is VoidType) { + Expression expression; + if (returnType is VoidType || isJSValueType(returnType)) { // Technically a `void` return value can still be used, by casting the // return type to `dynamic` or `Object?`. However this case should be // extremely rare, and `dartifyRaw` overhead for return values that will // never be used in practice is too much, so we avoid `dartifyRaw` on // `void` returns. We still box the `externref` as the value can be passed // around as a Dart object. - return StaticInvocation(jsValueBoxTarget, Arguments([invocation])); - } - Expression expression; - if (isJSValueType(returnType)) { // TODO(joshualitt): Expose boxed `JSNull` and `JSUndefined` to Dart // code after migrating existing users of js interop on Dart2Wasm. // expression = _createJSValue(invocation);