Change Intent
class Foo {
void noSuchMethod(Invocation i) => print(i.memberName);
}
void main() {
dynamic foo = Foo();
foo.bar;
}
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 by noSuchMethod forwarders and passed to noSuchMethod. In particular, it specifies that memberName is the name of the noSuchMethod-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 a noSuchMethod 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, only noSuchMethod-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
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
--minifyfrom affecting the result.Justification
The language spec mandates the behavior of the
Invocationthat is generated bynoSuchMethodforwarders and passed tonoSuchMethod. In particular, it specifies thatmemberNameis 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.memberNamein anoSuchMethodwhen 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
--minifyto 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