-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Analyzer cannot resolve instance reference on type variable, in a doc comment. #60417
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
I can take a look at this if you want me to 😁 |
@bwilkerson might be interested to consider whether we should fix this. I myself realized that it is perfectly reasonably to just write out the instance member on the bound (write If Brian looks at this, there is a 90% chance that he will think of something I haven't (other consequences, other reasons) 😁 . |
While I appreciate the flattery, I don't know that I have much to add. I don't know how often this style is used, but we do have an existence proof. I mention that because if it's rarely used then it might be better, from a maintence perspective, to not support it. From a purely theoretic perspective, it seems reasonable to be able to use a type parameter to reference a member as long as the type parameter has a bound that defines the member. We should flag cases where the bound doesn't define the member, but other than that I can't think of any issues, subtle or otherwise. We probably shouldn't, however, allow references to static members of the bound. I think that would be confusing. Just out of curiosity, do we handle typedefs? |
Fully agree. No, we don't handle typedefs but for them I'd say that static members could be allowed. Static members for type parameters should not show up because we can't enforce all sub classes have them (at least currently). |
One more point would be how to display that on dart doc pages but I guess it would get turned into the bound type, right? |
We do not support referencing members on typedefs. But this has been strongly requested for Flutter's SDK docs by @goderbauer here. For the purposes of incrementally renaming classes. |
I would assume that we'd want to display the text as it appears in the reference. It might make sense to link it to the bound, but it might be too magical. I don't have a strong opinion here yet.
That makes sense. |
Maybe something like |
The analyzer's "doc comment scope" is unable to resolve an instance getter reference on a type variable:
List.first
resolves properly, because we allow instance access as if it were static, on a type.T.first
does not resolve, even though there is afirst
property on the bound. Seems like this should be allowed.Came across this in DevTools code, and it seems reasonable.
The text was updated successfully, but these errors were encountered: