1
0
mirror of https://github.com/golang/go synced 2024-09-30 20:28:32 -06:00

internal/lsp: propagate context.Canceled when type checking

typeCheck() was swallowing context.Canceled errors and leaving the
cached package in a bad state. In particular, after two rapid changes
to imports I was left in the "no package for file" error mode until I
change my imports again. The second change canceled the first change
which ended up sticking a skeleton *pkg in the package cache instead
of propagating the canceled error.

Change-Id: I15b072188c3359d9cd1812bd49e72548ba214250
GitHub-Last-Rev: 240f61718fbb5bfc787bbfaaaae1d38925d7c405
GitHub-Pull-Request: golang/tools#126
Reviewed-on: https://go-review.googlesource.com/c/tools/+/183940
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Muir Manders 2019-06-26 23:28:06 +00:00 committed by Rebecca Stambler
parent 5d636af2a9
commit 47ea21585c

View File

@ -142,10 +142,12 @@ func (imp *importer) typeCheck(id packageID) (*pkg, error) {
wg.Wait()
for _, f := range files {
if f != nil {
pkg.files = append(pkg.files, f)
}
pkg.files = append(pkg.files, f)
if f.err != nil {
if f.err == context.Canceled {
return nil, f.err
}
imp.view.session.cache.appendPkgError(pkg, f.err)
}
}