-
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
Dart2js not treating (a.b)() the same as a.b(). #6428
Comments
Issue #6429 has been merged into this issue. |
I believe the spec holds in this case. |
Could you update the bug with information about what you see and what you'd expect to see? I'm guessing it's the difference between getting an InvocationMirror that's a getter rather than a method? Added this to the M2 milestone. |
Yes, exactly. |
So are you saying that the spec demands (a.b)(); to behave differently to var temp = a.b; ? |
I agree with Stephen that this is highly surprising and it certainly may trip up Dart-to-Dart translators if they aren't super careful. |
cc @larsbak. |
The intent of the spec was exactly the opposite: to make clear that e.m(...) is not the same as (e.m)(...). That is, given e.m(...), we do not first evaluate e.m and then do a call() which is what happens if you have the parentheses, but rather do a regular method invocation. So we need to be clear that the text that says "if e_f is a property access expression" applies to e.m but not to (e.m). I'll find away to rephrase this so it does not cause such confusion. Set owner to @gbracha. |
Ok, so this is not a dart2js error. Good, I'll adapt the test that depends on this. Would it make sense to define a closurized method as delegating the call to the original object? That means that o.m(...) and (o.m)(...) would act the same in all cases, not just with correct parameters. |
I don't think this is necessary. |
I've revised the relevant text to make this clear. |
Added Done label. |
Example code:
class C {
noSuchMethod(m) => m;
}
main() {
var c = new C();
var r = (c.bar)();
print(r);
}
According to the spec, this should do the same as if "c.bar" had not been parenthesized. From the section "Function Expression Invocation": "If e_f is a property access expression, then i is treated as an ordinary method invocation". In this case "(c.bar)" is a property access. (Or is it, Gilad? Are parentheses not just grouping here?)
The text was updated successfully, but these errors were encountered: