-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Doc comment references cannot resolve an extension member when prefixed by the extended type's name #56109
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 have a question.: do the references in doc comments refer to a type or to a declaration? I had always thought that they refer to a declaration, and that it didn't make sense. For example, we don't appear to support a reference such as References to inherited members are supported, but I view that as showing that we support references to all of the members of a declaration, not just the locally defined ones, rather than showing that we support types. If they do refer to a declaration rather than a type, then I think it's consistent that we don't support references to members on the extended type. |
Can you explain the difference? I'm not sure what "referring to a type" means in the context of Can they refer to whichever one allows this feature? Do we have to remove support for something else if we allow this feature? In other words, what is the downside choosing the one that allows this feature? |
Another way to ask the same question is: do the references in doc comments refer to a There is a class named I've always thought of The reason I think it's important is because the answer to that question implies a lot (to me, at least) about what we should and shouldn't support. If we're supporting elements, then the UX should be consistent with other references in code and it seems a lot better defined. If we're supporting types, then we have to answer more questions. If we're supporting types, then not only should we support But if we're only supporting elements, then I wouldn't support
I think I mostly answered those in the text above, but I think this feature is asking to support types in references rather than elements, I don't think we'd have to remove any other support, but I do think we'd need to add more support in order to be consistent with the change (or at least what I perceive to be a change). And I think that opens a can of worms that I'd rather leave closed, so that's one downside. The other downside I see is that |
I think I see. I think we should support types then, so that we can add enhancements like resolving
I think that supporting |
See also #47444 where I mention some other expansions I think we should do on comment references. |
I don't think the value proposition here is very high. For example, what does it add to support I can see more value for typedefs, because you might want to use a more domain-specific name, but I don't know how often users typedef one type to another like that. |
Consistency? If there is no problem with consistency then we don't need it. I thought you wanted it for consistency if we go the "refer to types" route.
Yes this is used internally. IMHO it is less helpful to document something like |
In #47444 you wrote that you thought we ought to support "type literal with type arguments (
Yes, I like consistency. I think that it's generally better from a UX perspective to be consistent. But I was actually using consistency as a reason to not go the "refer to types" route because I dislike the implications of that definition. In particular, no, I don't want to support I do, however, see your point about extension types. Perhaps if I squint just right I can convince myself that we're not opening the Pandora's box that allowing types would open and can live with the extension. |
I still do want that, type literals. I've seen lots of people write |
For the record, I don't think "sometimes people write x" to be a good argument for supporting that syntax, even when it's lots of people. I'd rather we didn't go there, but I could imagine supporting it as being equivalent to
I don't think that It's obvious that we have different ideas about this, and I doubt that I'll change your mind if I haven't already done so, so it's probably time for me to bow out gracefully. |
I was able to change some internal comments to reference the extension's name, so I don't see further request for this. |
CC @goderbauer |
We are running into a similar problem with typedefs in Flutter. We had to rename a type to cc @LongCatIsLooong, who ran into this issue. |
Take this example:
Today, you can refer to
m
in a doc comment reference by the extension name (/// [E.m]
), but not by the extended type's name (/// [String.m]
).I think it should be perfectly logical to refer to an extension member by the extended type's name. But there may be some quirks. E.g. given two extensions,
E on List<int>
andE on List<bool>
, each with a member namedm
. What does/// [List.m]
refer to? There are rules about resolving extension members and "specificity," which can probably apply without modification to comment references. We just have to start with a rule about instantiating the type to bounds. And probably make it non-nullable, so that it can refer to anextension E on String?
.The text was updated successfully, but these errors were encountered: