[gopls-release-branch.0.4] 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>
(cherry picked from commit 449c585133f022949997079b2cc2e75636d11b2b)
Reviewed-on: https://go-review.googlesource.com/c/tools/+/245538
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
diff --git a/internal/lsp/source/hover.go b/internal/lsp/source/hover.go
index d8ba9a0..3604dbb 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 2cabd93..8cf075c 100644
--- a/internal/lsp/source/identifier.go
+++ b/internal/lsp/source/identifier.go
@@ -256,9 +256,6 @@
 						}
 					}
 				}
-				if exported == nil {
-					return nil
-				}
 				return exported
 			}
 		case *ast.CompositeLit: