internal/lsp/source: add a nil check on the identifier's object in implementation
If the identifier doesn't have type info, don't try to access it.
Change-Id: I7e7c834c2863ec82a1269e60f7c50b0ce03f4692
Reviewed-on: https://go-review.googlesource.com/c/tools/+/204740
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
diff --git a/internal/lsp/source/implementation.go b/internal/lsp/source/implementation.go
index a28b38f..bcfcc06 100644
--- a/internal/lsp/source/implementation.go
+++ b/internal/lsp/source/implementation.go
@@ -11,6 +11,7 @@
import (
"context"
+ "errors"
"go/types"
"sort"
@@ -64,6 +65,9 @@
}
func (i *IdentifierInfo) implementations(ctx context.Context) (implementsResult, error) {
+ if i.Type.Object == nil {
+ return implementsResult{}, errors.New("no type info object for identifier")
+ }
T := i.Type.Object.Type()
// Find all named types, even local types (which can have