Skip to content
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: 'implementations' doesn't work with generics #59224

Open
adonovan opened this issue Mar 24, 2023 · 6 comments
Open

x/tools/gopls: 'implementations' doesn't work with generics #59224

adonovan opened this issue Mar 24, 2023 · 6 comments
Assignees
Labels
gopls/generics Issues related to gopls' support for generics NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@adonovan
Copy link
Member

Even some of the most basic scenarios of 'implementations' are not working at all with generics, for example when the concrete and interface types are both generalized over [T any] and are defined within the same file:

xtools$ cat d/d.go 
package d

type Collection[T any] interface {
	Push(T) error
	Pop() (*T, bool)
}

type C[T any] struct{}

func (C[T]) Push(t T) error { return nil }

func (C[T]) Pop() (*T, bool) {
	var t T
	return &t, true
}

var _ Collection[int] = C[int]{}

xtools$ go run ./gopls implementation ./d/d.go:#120  # within "Push" concrete method identifier
xtools$

This is not a recent regression:

xtools$ ./gopls-v0.11.0 implementation ./d/d.go:#120  
xtools$

A similar lack of results is obtained by querying the Push abstract method, or the Collection interface, or the C concrete type.

(This test case was a further reduction of the one described in https://youtrack.jetbrains.com/issue/GO-12702/Go-to-Declaration-Implementation-not-available-for-generics-interfaces, referenced by golang/vscode-go#2711.)

@adonovan adonovan self-assigned this Mar 24, 2023
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Mar 24, 2023
@gopherbot gopherbot added this to the Unreleased milestone Mar 24, 2023
@adonovan adonovan added gopls/generics Issues related to gopls' support for generics NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. and removed gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. labels Mar 24, 2023
@linjunhao1997
Copy link

I think this is urgently needed

@fangjh13
Copy link

I would like to know how the progress is going, it's really needed.

@adonovan
Copy link
Member Author

I would like to know how the progress is going, it's really needed.

No progress, sorry. Haven't even designed the algorithm yet. But let's make it a priority for 0.13.

@ajsqr
Copy link

ajsqr commented Feb 9, 2024

Hello, is a fix for this planned in the upcoming release ?

@Solverj
Copy link

Solverj commented Feb 9, 2024

I'm also currently googling / gpting / searching, atm I have to make tests on a struct to verify that I've created structs according to generic interface in neovim.

@adonovan
Copy link
Member Author

adonovan commented Feb 9, 2024

Hello, is a fix for this planned in the upcoming release ?

Unfortunately no, but likely the following one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls/generics Issues related to gopls' support for generics NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

7 participants