From 4f29fbcc08757151cf2bf84e645ffa5e057d9c3b Mon Sep 17 00:00:00 2001 From: Rohan Challa Date: Thu, 19 Dec 2019 10:01:26 -0500 Subject: [PATCH] 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 Run-TryBot: Rohan Challa TryBot-Result: Gobot Gobot --- go/packages/golist.go | 5 +++-- internal/lsp/source/diagnostics.go | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/go/packages/golist.go b/go/packages/golist.go index 9c895b3895..2ac7c02a3b 100644 --- a/go/packages/golist.go +++ b/go/packages/golist.go @@ -811,8 +811,9 @@ func golistDriver(cfg *Config, rootsDirs func() *goInfo, words ...string) (*driv 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 dbc94502b0..9d3c8d41d2 100644 --- a/internal/lsp/source/diagnostics.go +++ b/internal/lsp/source/diagnostics.go @@ -72,7 +72,7 @@ func Diagnostics(ctx context.Context, snapshot Snapshot, f File, withAnalysis bo // 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 @@ func diagnostics(ctx context.Context, snapshot Snapshot, pkg Package, reports ma 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" }