Skip to content

Commit a3e2431

Browse files
osa1Commit Queue
authored andcommitted
[dart2wasm] Simplify void JS return value boxing
Change-Id: I875a8e0bc83f2338b74060e871f22a02ef808755 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/422301 Reviewed-by: Nate Biggs <[email protected]> Commit-Queue: Ömer Ağacan <[email protected]>
1 parent 1d69b0b commit a3e2431

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

pkg/dart2wasm/lib/js/util.dart

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,18 +285,15 @@ class CoreTypesUtil {
285285
/// Cast the [invocation] if needed to conform to the expected [returnType].
286286
Expression castInvocationForReturn(
287287
Expression invocation, DartType returnType) {
288-
if (returnType is VoidType) {
288+
Expression expression;
289+
if (returnType is VoidType || isJSValueType(returnType)) {
289290
// Technically a `void` return value can still be used, by casting the
290291
// return type to `dynamic` or `Object?`. However this case should be
291292
// extremely rare, and `dartifyRaw` overhead for return values that will
292293
// never be used in practice is too much, so we avoid `dartifyRaw` on
293294
// `void` returns. We still box the `externref` as the value can be passed
294295
// around as a Dart object.
295-
return StaticInvocation(jsValueBoxTarget, Arguments([invocation]));
296-
}
297296

298-
Expression expression;
299-
if (isJSValueType(returnType)) {
300297
// TODO(joshualitt): Expose boxed `JSNull` and `JSUndefined` to Dart
301298
// code after migrating existing users of js interop on Dart2Wasm.
302299
// expression = _createJSValue(invocation);

0 commit comments

Comments
 (0)