[breaking change][dart2js] Stop minifying Invocation.memberName in noSuchMethod #54201
Labels
area-web-js
Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop
breaking-change-approved
breaking-change-request
This tracks requests for feedback on breaking changes
web-dart2js
Change Intent
Ordinarily, this program will print
Symbol("bar")
with dart2js, as expected. When compiled with--minify
, however, it will print, e.g.Symbol("gB")
(or whatever minified name is chosen).This change will stop
--minify
from affecting the result.Justification
The language spec mandates the behavior of the
Invocation
that is generated bynoSuchMethod
forwarders and passed tonoSuchMethod
. In particular, it specifies thatmemberName
is the name of thenoSuchMethod
-forwarded method. (Note that this is the name as it appears in the source code, not the compiled output.)Making this change improves our spec conformance and has the added benefit of causing several nSM-reliant SDK tests to start passing on minified dart2js configurations.
Impact
There's unlikely to be any impact to the semantics of programs. In order to observe the change in behavior, one would need to rely on the value of
Invocation.memberName
in anoSuchMethod
when building with--minify
.Note that the minified name would have changed frequently already, and there's not much you can do with the resulting symbol in Dart.
@sigmundch points out that some users may be relying on
--minify
to obscure method names which may leak internal details. IMO, it's poor security to depend on minification for this, but in any case, onlynoSuchMethod
-forwarded names can leak, so if developers are avoiding nSM, there's no issue.Mitigation
Unless we add a flag for this (which seems like overkill), I don't think there is actually a way to mitigate impact if it occurs.
Change Timeline
ASAP
Associated CLs
https://dart-review.googlesource.com/c/sdk/+/338947
The text was updated successfully, but these errors were encountered: