internal/lsp: fix nil pointer when propagating diagnostics

Fixes golang/go#32030

Change-Id: I5ae7f2dc68c68c1a4851c637dcb75f312b0b35f5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/177057
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
diff --git a/internal/lsp/source/diagnostics.go b/internal/lsp/source/diagnostics.go
index 4b3b94c..032c4af 100644
--- a/internal/lsp/source/diagnostics.go
+++ b/internal/lsp/source/diagnostics.go
@@ -74,6 +74,9 @@
 	// Updates to the diagnostics for this package may need to be propagated.
 	for _, f := range f.GetActiveReverseDeps(ctx) {
 		pkg := f.GetPackage(ctx)
+		if pkg == nil {
+			continue
+		}
 		for _, filename := range pkg.GetFilenames() {
 			reports[span.FileURI(filename)] = []Diagnostic{}
 		}