internal/lsp/source: handle a possible nil pointer in call hierarchy

Change-Id: I90e7b09853485cfd99a99eadd534e47fe69fb1ca
Reviewed-on: https://go-review.googlesource.com/c/tools/+/260800
Trust: Rebecca Stambler <rstambler@golang.org>
Trust: Danish Dua <danishdua@google.com>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Danish Dua <danishdua@google.com>
diff --git a/internal/lsp/source/call_hierarchy.go b/internal/lsp/source/call_hierarchy.go
index 62de3ab..7a521ed 100644
--- a/internal/lsp/source/call_hierarchy.go
+++ b/internal/lsp/source/call_hierarchy.go
@@ -32,6 +32,10 @@
 		}
 		return nil, err
 	}
+	// The identifier can be nil if it is an import spec.
+	if identifier == nil {
+		return nil, nil
+	}
 
 	if _, ok := identifier.Declaration.obj.Type().Underlying().(*types.Signature); !ok {
 		return nil, nil