From a860bcda08c71ba41c6f8ed10f5baa5fd95e32cf Mon Sep 17 00:00:00 2001 From: Michael Matloob Date: Fri, 1 Nov 2019 12:23:20 -0400 Subject: [PATCH] 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 Reviewed-by: Rebecca Stambler TryBot-Result: Gobot Gobot --- 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 a28b38f6823..bcfcc06587d 100644 --- a/internal/lsp/source/implementation.go +++ b/internal/lsp/source/implementation.go @@ -11,6 +11,7 @@ package source import ( "context" + "errors" "go/types" "sort" @@ -64,6 +65,9 @@ func Implementation(ctx context.Context, view View, f File, position protocol.Po } 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