-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[cfe] LibraryIndex
throws when getting instance members that have name collisions with named constructors
#59910
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
Weirdly, the spec allows instance members and constructors with the same name (but not static members and constructors with the same name) - a fact that I wasn't aware of until recently. It might be that the library index also assumes that we cannot have instance members and constructors of the same name. |
I think the motivation for allowing class A {
A.foo();
void foo() {}
} was that there is no location in code where the constructor is denoted by For a static member and an instance member there is a name clash. This occurs already at the fundamental scoping level because |
There would be a name clash in dart docs (I think?) What would happen when you do: /// Text for [A.foo] |
Good point, it does make sense to refer to the declaration as such using However, it's a breaking change to make it a name conflict in the language. Perhaps it should just be handled by the DartDoc tool by adding some special syntax to disambiguate this case? |
Dartdoc prefers the |
So if you add We'll need more disambiguation if we allow static and instance members with the same name. Especially if the static one is a getter, where the |
If you have a simple class like this:
and compile it to a component, then try to access the field via a library index:
You get an error message like this:
cc @jensjoha
The text was updated successfully, but these errors were encountered: