-
Notifications
You must be signed in to change notification settings - Fork 1.7k
The dot-shorthands
feature is not working in some operator expressions.
#60671
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
Comments
FYI @kallentu |
I think it is working as intended. In an expression like |
@mraleph the type of the variable is used as lookup context when doing a dot-shorthand. The following works for example: int a = .parse('-1').abs(); But it obviously would not work for: var a = .parse('-1').abs(); |
The spec mentions these cases specifically. Search NOT ALLOWED, ALL .id ARE ERRORS! in the specification. |
Alright it does mention this case as an error. I guess the question then is how come operators can't get a context type for the left hand side? |
Had to think about this for a while because it seemed nonintuitive, but the decision seems to make sense. Consider we do something odd class MyInt
{ final int mine;
MyInt(this.mine);
int operator +(int i)
{ return mine+i;
}
// ...
} Suppose |
It fails when using the shorthand in the left-hand side of a binary operator:
It fails when using some unary operators:
The text was updated successfully, but these errors were encountered: