Skip to content

Commit 1dc58ee

Browse files
committed
gopls/internal/lsp: add go to implementation support for function types
Fixes #56572 fix: add null check from commit 13648cd
1 parent 34e4ae7 commit 1dc58ee

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

gopls/internal/lsp/source/implementation.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,23 @@ func implementations(ctx context.Context, s Snapshot, f FileHandle, pp protocol.
116116
}
117117
seen := make(map[token.Position]bool)
118118
for _, obj := range objs {
119-
pos := s.FileSet().Position(obj.Pos())
120-
if seen[pos] {
119+
pkg := pkgs[obj.Pkg()] // may be nil (e.g. error)
120+
121+
// TODO(adonovan): the logic below assumes there is only one
122+
// predeclared (pkg=nil) object of interest, the error type.
123+
// That could change in a future version of Go.
124+
125+
var posn token.Position
126+
if pkg != nil {
127+
posn = pkg.FileSet().Position(obj.Pos())
128+
}
129+
if seen[posn] {
121130
continue
122131
}
123-
seen[pos] = true
132+
seen[posn] = true
124133
impls = append(impls, qualifiedObject{
125134
obj: obj,
126-
pkg: pkgs[obj.Pkg()], // may be nil (e.g. error)
135+
pkg: pkg,
127136
})
128137
}
129138

0 commit comments

Comments
 (0)