go/packages: change import cycle errorkind from UnknownError to ListError
The import cycle not allowed error should be returned as a ListError not
an UnknownError.
Fixes golang/go#35964
Change-Id: Ibc575f92d926ff715c0da67a4fceda05badcc652
Reviewed-on: https://go-review.googlesource.com/c/tools/+/212138
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rohan Challa <rohan@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
diff --git a/go/packages/golist.go b/go/packages/golist.go
index 9c895b3..2ac7c02 100644
--- a/go/packages/golist.go
+++ b/go/packages/golist.go
@@ -811,8 +811,9 @@
msg += fmt.Sprintf(": import stack: %v", p.Error.ImportStack)
}
pkg.Errors = append(pkg.Errors, Error{
- Pos: p.Error.Pos,
- Msg: msg,
+ Pos: p.Error.Pos,
+ Msg: msg,
+ Kind: ListError,
})
}
diff --git a/internal/lsp/source/diagnostics.go b/internal/lsp/source/diagnostics.go
index dbc9450..9d3c8d4 100644
--- a/internal/lsp/source/diagnostics.go
+++ b/internal/lsp/source/diagnostics.go
@@ -72,7 +72,7 @@
// Prepare any additional reports for the errors in this package.
for _, e := range pkg.GetErrors() {
// We only need to handle lower-level errors.
- if !(e.Kind == UnknownError || e.Kind == ListError) {
+ if e.Kind != ListError {
continue
}
// If no file is associated with the error, default to the current file.
@@ -138,7 +138,7 @@
case TypeError:
set.typeErrors = append(set.typeErrors, diag)
diag.Source = "compiler"
- case ListError, UnknownError:
+ case ListError:
set.listErrors = append(set.listErrors, diag)
diag.Source = "go list"
}