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
go/types: maintain "owner" information for interface methods and struct fields #8178
Comments
@adonovan Is this still of interest? If so, please comment on this issue and mark for 1.11, "early in cycle" and I'll try to address it. Thanks. |
I just ran into this limitation, too, when working on a tool to surface “// Deprecated: ” comments. (See Google-internal cl/478490109 for more context.) My code works by iterating through Currently, I can’t surface deprecation warnings for struct fields (only for the struct type itself, or methods on it) because of this limitation. @griesemer Would you still be interested in looking into this? Timing-wise, the 1.21 cycle should start soon, so perhaps this is an opportune moment. Thank you! |
@stapelberg Marking for 1.21 so it's on the radar as we may look into some changes in this space. But exposing the information would be an API change which would require a (if small) proposal. |
Thank you! Let me know if there’s anything I can help with, happy to try out a pending change or similar :) |
I have learned to live with this design, so don't keep this open on my account. |
We’re still interested in this! (Though, now that I read Alan’s comment, maybe I should try again to find a workaround for our use-case. I’ll try that as time permits.) |
FWIW, now that the export and import of type information preserves precise positions, you could use the position of the field to resolve the ambiguity: the named struct type whose position most closely precedes the field position is its "owner". |
Just to be clear, we could easily maintain an owner link but at least for go/types this would require an API change if it needs to be accessible externally. That would require a proposal. For now put on Backlog. Feel free to "reactivate" (and send out a proposal) if this continues to be important. Also, feel free to close if no need. |
We managed to work around this issue as well: we now look at the AST, and when we find a KeyValueExpr, we go back up the stack to the containing CompositeLit to extract its type. I’ll close this issue, but please report back in case anyone has a use-case where this limitation cannot be worked around. |
I ran into this as well, and ended up using a |
The text was updated successfully, but these errors were encountered: