aboutsummaryrefslogtreecommitdiff
path: root/gopls/internal/lsp/source/implementation2.go
diff options
context:
space:
mode:
Diffstat (limited to 'gopls/internal/lsp/source/implementation2.go')
-rw-r--r--gopls/internal/lsp/source/implementation2.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/gopls/internal/lsp/source/implementation2.go b/gopls/internal/lsp/source/implementation2.go
index 4a8e829a8..7ca2e087e 100644
--- a/gopls/internal/lsp/source/implementation2.go
+++ b/gopls/internal/lsp/source/implementation2.go
@@ -274,7 +274,13 @@ func typeDeclPosition(ctx context.Context, snapshot Snapshot, uri span.URI, ppos
// Is the object a type or method? Reject other kinds.
var methodID string
- obj := pkg.GetTypesInfo().ObjectOf(id)
+ obj := pkg.GetTypesInfo().Uses[id]
+ if obj == nil {
+ // Check uses first (unlike ObjectOf) so that T in
+ // struct{T} is treated as a reference to a type,
+ // not a declaration of a field.
+ obj = pkg.GetTypesInfo().Defs[id]
+ }
switch obj := obj.(type) {
case *types.TypeName:
// ok