internal/lsp: properly check for nil on i.enclosing
Fixes golang/go#40479
Change-Id: If827a86fd603574d3adde295c1165bb6267732eb
Reviewed-on: https://go-review.googlesource.com/c/tools/+/245486
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
diff --git a/internal/lsp/source/hover.go b/internal/lsp/source/hover.go
index 02d20ab..e26a8b7 100644
--- a/internal/lsp/source/hover.go
+++ b/internal/lsp/source/hover.go
@@ -166,7 +166,7 @@
// exported (we may have an interface or struct we can link
// to). If not, don't show any link.
if !rtyp.Obj().Exported() {
- if named := i.enclosing.(*types.Named); ok && named.Obj().Exported() {
+ if named, ok := i.enclosing.(*types.Named); ok && named.Obj().Exported() {
rTypeName = named.Obj().Name()
} else {
return "", "", ""
diff --git a/internal/lsp/source/identifier.go b/internal/lsp/source/identifier.go
index f892780..d4f9591 100644
--- a/internal/lsp/source/identifier.go
+++ b/internal/lsp/source/identifier.go
@@ -248,9 +248,6 @@
}
}
}
- if exported == nil {
- return nil
- }
return exported
}
case *ast.CompositeLit: