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: regression in implementationsV2 for concrete methods #58506

Closed
adonovan opened this issue Feb 13, 2023 · 1 comment
Closed

x/tools/gopls: regression in implementationsV2 for concrete methods #58506

adonovan opened this issue Feb 13, 2023 · 1 comment
Assignees
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@adonovan
Copy link
Member

example$ head -99 $(find . -type f)
==> ./go.mod <==
module example.com

go 1.12

==> ./a/a.go <==
package a

type A int

func (A) F() {}

==> ./b/b.go <==
package b

import (
	"example.com/a"
	"example.com/c"
)

type B interface{ F() }

var _ B = a.A(0)
var _ B = c.C(0)

var _ = B.F

==> ./c/c.go <==
package c

type C int

func (C) F() {}

==> ./d/d.go <==
package d

import "example.com/b"

var _ interface{} = b.B.F

example$ ../xtools/gopls-v0.7.5  references   ./a/a.go:#33 
/Users/adonovan/w/example/b/b.go:13:11-12
/Users/adonovan/w/example/d/d.go:5:25-26
example$ ../xtools/gopls-v0.11.0 references   ./a/a.go:#33 
/Users/adonovan/w/example/b/b.go:13:11-12
/Users/adonovan/w/example/d/d.go:5:25-26
example$ ../xtools/gopls.head  references   ./a/a.go:#33 
/Users/adonovan/w/example/d/d.go:5:25-26

This example applies the "implementations" query to method A.F. The correct answer includes both references to B.F, one in package b and one in package d. However, the new ("v2") implementation of "implementations" fails to report the reference from package b.

The reason is that v2 has completely different algorithms for the local and global cases (with disjoint results), and when it discovers that type A satisfies interface B and thus that it must include B.F among the global search targets, it forgets to search package b for local references to B.F.

@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 Feb 13, 2023
@gopherbot gopherbot added this to the Unreleased milestone Feb 13, 2023
@adonovan adonovan modified the milestones: Unreleased, gopls/v0.12.0 Feb 13, 2023
@adonovan adonovan self-assigned this Feb 13, 2023
@gopherbot
Copy link

Change https://go.dev/cl/479315 mentions this issue: gopls/internal/lsp/source: fix references expansion bug

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

2 participants