-
Notifications
You must be signed in to change notification settings - Fork 1.7k
It is OK to have a setter with the same name as the enclosing class #30834
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
No wrong code should be generated, of course, but given that the language specification has 'It is a compile time error if a class |
The name of the setter is |
Sorry, you're right! |
/cc @askeksa-google |
The above code currently gives an internalProblem in fasta:
|
I consider known crashes to be P1. Aske, could you take a look? |
We're probably going to fix that loop-hole. It's not helping anyone to be able to declare a setter and not be allowed to declare the corresponding getter. |
@lrhn, I agree. But from the perspective of Fasta, this is just another case of duplicated names, and we have to handle those gracefully anyways. We can't stop code completion just because there's a duplicated member. Sometimes, the way we recover from parser errors also makes us think there's a duplicated member. For example:
We currently recover from this code by inventing a top-level method A(). |
@lrhn wrote:
One of the things implied by this CL is that it is an error to have a setter (instance or static) whose basename is the same as the name of the enclosing class, which is basically a revert on the CL that closed this issue (https://dart-review.googlesource.com/34120). A 'basename' is the same as the name for all members, except that it strips off the It is also the consistent choice, considering all the other rules about class member name conflicts. WDYT, would it break any significant amount of existing code to revert the CL that closed this issue (with adjustments as needed, because other things have changed since then)? |
This code is OK for Analyzer and VM, but Fasta produces wrong Kernel for it.
The text was updated successfully, but these errors were encountered: