mirror of
https://github.com/golang/go
synced 2024-11-18 20:04:52 -07:00
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>
This commit is contained in:
parent
f02a19dded
commit
a860bcda08
@ -11,6 +11,7 @@ package source
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"go/types"
|
"go/types"
|
||||||
"sort"
|
"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) {
|
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()
|
T := i.Type.Object.Type()
|
||||||
|
|
||||||
// Find all named types, even local types (which can have
|
// Find all named types, even local types (which can have
|
||||||
|
Loading…
Reference in New Issue
Block a user