[CP] Erase static interop type in static invocation #53579
Labels
area-web
Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop.
cherry-pick-approved
Label for approved cherrypick request
cherry-pick-review
Issue that need cherry pick triage to approve
merge-to-stable
web-dart2js
web-js-interop
Issues that impact all js interop
Commit(s) to merge
b25873f
Target
stable
Prepared changelist for beta/stable
https://dart-review.googlesource.com/c/sdk/+/327120
Issue Description
@anonymous
@staticInterop
classes using type parameters with factories crash on dart2js. An insufficient erasure led to a type mismatch in generated tear-offs that call these factories, which then triggered a crash. This is platform-agnostic but only materializes in dart2js.What is the fix
The fix casts the invocation of the
@staticInterop
factory invocation to its erased type so that there isn't a type mismatch.Why cherry-pick
This is an issue that is difficult to work around for users. Per my comment in #53479 (comment), users are forced to either move the factory to a static method, which won't be able to use class type parameters, use a top-level method, or get rid of class type parameters. All of these fixes will require breaking changes to users' packages to work around. Naturally, it's a breaking change again to go back to the old syntax once the issue is fixed. There is at least one existing package impacted by this: https://pub.dev/packages/record.
Risk
low
Issue link(s)
#53291 #53479 #53337
Extra Info
Note that the prepared changelist is slightly modified from the original CL. The only changes are in the test in that CL to support the fact that we didn't allow type parameters in extension members of
@staticInterop
classes (hence theObject?
instead ofT
andU
).The text was updated successfully, but these errors were encountered: