1
0
mirror of https://github.com/golang/go synced 2024-10-01 11:18:32 -06:00
go/internal/lsp/testdata/implementation/implementation.go
Muir Manders a6aac22fcd internal/lsp: fix find-implementation for promoted methods
We weren't returning promoted methods as implementations when the
promoted method was defined in a different package than the type
implementing the interface.

Fix by properly mapping the implementer types.Object to its containing
source.Package.

I generalized the implementations() result to just contain the
implementer objects and their containing package. This allowed me to
get rid of some result prep code in Implementation().

Fixes golang/go#35972.

Change-Id: I867f2114c34e2ad39515ee3c8b6354c1cd35f7af
Reviewed-on: https://go-review.googlesource.com/c/tools/+/210280
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
2019-12-16 21:36:29 +00:00

34 lines
683 B
Go

package implementation
import "golang.org/x/tools/internal/lsp/implementation/other"
type ImpP struct{} //@ImpP
func (*ImpP) Laugh() { //@mark(LaughP, "Laugh")
}
type ImpS struct{} //@ImpS
func (ImpS) Laugh() { //@mark(LaughS, "Laugh")
}
type ImpI interface {
Laugh() //@implementations("Laugh", LaughP, OtherLaughP, LaughS, OtherLaughS)
}
type Laugher interface { //@implementations("Laugher", ImpP, OtherImpP, ImpS, OtherImpS)
Laugh() //@implementations("Laugh", LaughP, OtherLaughP, LaughS, OtherLaughS)
}
type Foo struct {
other.Foo
}
type U interface {
U() //@implementations("U", ImpU)
}
type cryer int
func (cryer) Cry(other.CryType) {} //@mark(CryImpl, "Cry")