From f3748ed8ec89697f45bdc785f5dbc97679e75a35 Mon Sep 17 00:00:00 2001 From: Rob Findley Date: Thu, 18 Feb 2021 16:26:44 -0500 Subject: [PATCH] internal/lsp/source: filter out comparable from completion results The comparable interface is introduced on the dev.typeparams branch. Filter it out from gopls completion results so that it doesn't break tests on the dev.typeparams branch. Change-Id: Iba22c0980c09e99b454ce9e22813cc3a1f94a90c Reviewed-on: https://go-review.googlesource.com/c/tools/+/293931 Trust: Robert Findley Run-TryBot: Robert Findley Reviewed-by: Rebecca Stambler gopls-CI: kokoro TryBot-Result: Go Bot --- internal/lsp/source/completion/completion.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internal/lsp/source/completion/completion.go b/internal/lsp/source/completion/completion.go index 9ebdc1c137..4689b76d00 100644 --- a/internal/lsp/source/completion/completion.go +++ b/internal/lsp/source/completion/completion.go @@ -1264,6 +1264,11 @@ func (c *completer) lexical(ctx context.Context) error { var ( builtinIota = types.Universe.Lookup("iota") builtinNil = types.Universe.Lookup("nil") + // comparable is an interface that exists on the dev.typeparams Go branch. + // Filter it out from completion results to stabilize tests. + // TODO(rFindley) update (or remove) our handling for comparable once the + // type parameter API has stabilized. + builtinComparable = types.Universe.Lookup("comparable") ) // Track seen variables to avoid showing completions for shadowed variables. @@ -1282,6 +1287,9 @@ func (c *completer) lexical(ctx context.Context) error { if declScope != scope { continue // Name was declared in some enclosing scope, or not at all. } + if obj == builtinComparable { + continue + } // If obj's type is invalid, find the AST node that defines the lexical block // containing the declaration of obj. Don't resolve types for packages.