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
x/tools/gopls: gopls can't "Go to implementation" for generic interface methods #61801
Comments
Thank you for the issue. First of all, the bug reports are a red herring. It turns out that the reported failure can be expected in certain situations, and this report was removed in https://go.dev/cl/514575. Where did you observe these reports? I was aware of the incompleteness of implementations for generic interfaces, and thought we already had an open issue, but can't find it. Thank you for writing it up so diligently. There is a bit of an open question about what it means for an type to implement a generic interface: does it mean that there's a theoretical instantiation of the type that implements the interface? Does it mean that the type implements all instantiations of the interface? Does it mean that the type is generic, and pairwise instantiations of the type and interface implement eachother? Nevertheless, I think we can come up with a reasonable definition, and do better than we do now. Probably the following is what we want: A (possibly generic) type T implements a (possibly generic) interface I if:
Answering these correctly will require type unification, but we could perhaps do something weaker that is close enough. |
Thanks for the speedy answer!
I ran
I was sure there was going to be one, but also couldn't find it. Happy to close this once we find it to be a duplicate.
Yeah, it wasn't entirely clear to me what to expect, either. In practice, though, it seems to me that I'm interested in the following:
Not sure how general those preferences are, however. I've also just realised that going from the (generic) implementation to the interface already works. |
Aha, I found the existing issue: #59224 Let's consolidate discussion there. |
What did you do?
In the following program, I would like to find implementations of
Resource[T].Store()
, but gopls doesn't find the two implementations.Repro: https://go.dev/play/p/E74QMj99O8z
(asked on gopher slack before filing, sticking around for a bit to answer questions: https://gophers.slack.com/archives/CJZH85XCZ/p1691048076576599)
What did you expect to see?
Placing the cursor on
Resource[T].Store
, I pressed the shortcut for go to implementation. I expected to see both implementations listed:and
What did you see instead?
an LSP error, saying
Not found for: Store
Internal errors
Note that these internal errors are only tangentially related. The reproduction is a minified version of the
cilium/cilium/pkg/k8s/resource
package implicated below, but the error below doesn't occur on the minimal repro - something else is going on.Gopls detected 3 internal errors, 1 distinct:
Build info
The text was updated successfully, but these errors were encountered: