-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
some member names likely don't work right for types with "call" method #27647
Comments
CC @alan-knight who saw a related issue |
We needed to work around this issue to use the DDC, so I implemented a runtime fix to the issue with the It's hacky and brittle and I'm not super proud of it, but it gets the job done if you really need to work around this issue. |
Here's a test demonstrating the issues: class Foo {
final name = 'FOO!';
final length = 123;
call() => 'hello world';
bind(int x) => x + 40;
apply(x, y) => 'called apply($x, $y)';
}
main() {
var f = new Foo();
print(f());
// Fails because Dart sets these with `this.name =` and `this.length =` and
// that's ignored because the data properties are not writable
// (http://www.ecma-international.org/ecma-262/6.0/#sec-function.length)
print(f.name);
print(f.length);
// works because Dart method shadows the JS ones (probably breaks JS interop)
print(f.apply(1, 2));
print(f.bind(2));
// This happens to work because DDC checks `f instanceof Function` rather than
// `typeof f == "function"`, causing it to tearoff the `call` method rather
// than directly calling `f.apply`.
print((f as dynamic)());
} One way to fix this would be to treat classes with |
this was fixed. callable classes are not subtypes of function types any longer, so we do not represent them the same way in JS |
(moved from dart-archive/dev_compiler#593)
In particular, those that are inherited from JS Functions, like "name" and "length".
We also allow shadowing methods like "call" and "apply". This may cause problems in our runtime, or in JS code that gets these objects. We should probably symbolize call/apply to avoid collision.
The text was updated successfully, but these errors were encountered: