internal/lsp: fix regression from CL 179439

Fixes golang/go#32378

Change-Id: I7c5b794ba6137084a56e3e7bf8027a6f65819b34
Reviewed-on: https://go-review.googlesource.com/c/tools/+/179919
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
diff --git a/internal/lsp/cache/pkg.go b/internal/lsp/cache/pkg.go
index eeb1403..9cf86b4 100644
--- a/internal/lsp/cache/pkg.go
+++ b/internal/lsp/cache/pkg.go
@@ -161,5 +161,9 @@
 }
 
 func (pkg *pkg) GetImport(pkgPath string) source.Package {
-	return pkg.imports[pkgPath]
+	if imp := pkg.imports[pkgPath]; imp != nil {
+		return imp
+	}
+	// Don't return a nil pointer because that still satisfies the interface.
+	return nil
 }