ExternalDartReference.toDartObject
and Object.toExternalReference
should support a null
receiver
#55339
Labels
area-web-js
Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.
web-js-interop
Issues that impact all js interop
Both
ExternalDartReference.toDartObject
andObject.toExternalReference
are defined as extensions on non-null types.This poses a problem for generic APIs which could contain null:
Note the implementation of the wrapper function must use
?.
to access bothtoDartObject
andtoExternalReference
becauseT
could be parameterized with a nullable type.This causes
dart2js
to emit rather inefficient JavaScript:If I'm not mistaken, isn't this simply equivalent to:
(Which could potentially be further inlined).
Could we simply redefine these extensions on
Object?
andExternalDartReference?
, removing the need for the?.
access?@srujzs
The text was updated successfully, but these errors were encountered: