From 73db347c3b7cb8dddf5cb12d7637682d56758cf4 Mon Sep 17 00:00:00 2001 From: Rohan Challa Date: Mon, 25 Nov 2019 14:40:42 -0500 Subject: [PATCH] internal/lsp: do not return interface itself when finding implementations Finding implementations of an interface should not give the interface itself as an implementation. Fixes #35601 Change-Id: Id3352619ece90fb7ca906ddabca613742d156c76 Reviewed-on: https://go-review.googlesource.com/c/tools/+/208667 Run-TryBot: Rohan Challa TryBot-Result: Gobot Gobot Reviewed-by: Rebecca Stambler --- internal/lsp/source/implementation.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/lsp/source/implementation.go b/internal/lsp/source/implementation.go index 486e3b1dac..7702b8e2c6 100644 --- a/internal/lsp/source/implementation.go +++ b/internal/lsp/source/implementation.go @@ -77,6 +77,10 @@ func (i *IdentifierInfo) Implementation(ctx context.Context) ([]protocol.Locatio if err != nil { return nil, err } + // Do not add interface itself to the list. + if ident.Declaration.spanRange == i.Declaration.spanRange { + continue + } locations = append(locations, protocol.Location{ URI: protocol.NewURI(ident.Declaration.URI()), Range: decRange,