[dart2wasm] Simplify void JS return value boxing
Change-Id: I875a8e0bc83f2338b74060e871f22a02ef808755 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/422301 Reviewed-by: Nate Biggs <natebiggs@google.com> Commit-Queue: Ömer Ağacan <omersa@google.com>
This commit is contained in:
committed by
Commit Queue
parent
1d69b0b980
commit
a3e243154c
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user