go/internal
Alan Donovan ce26db4201 go/analysis: add Pass.TypeErrors field
The result of type checking is a package (types.Package), type
annotations on syntax trees (types.Info), and zero or more type
errors (types.Error).  Hitherto we had assumed that analyzers don't
need access to type errors, but in fact it turns out to be useful:
for example, analyzers can look at broken code and suggest quick
fixes to repair the mistakes.

This change adds a Pass.TypeErrors field that holds the errors
produced during type checking. It may be non-nil only when the
Analyzer.RunDespiteErrors flag was enabled. Similarly, it adds
a TypeErrors field to go/packages.Package.
(The existing Packages.Error field loses important details.)

Gopls was already using analyzers in this way, (ab)using its privileged
position in the x/tools repo. This change removes the need for such hacks.

We expect that all analysis drivers that support RunDespiteErrors will
in due course populate the Pass.TypesErrors field. This change updates
the go/packages-based driver to do so; no changes were needed to
unitchecker since it does not support RunDespiteErrors.
In the meantime, not populating this field is not expected to cause
any compatibility problems.

Fixes golang/go#54619

Change-Id: Ia7c72242e332782e8919a4c30b2107c37bcec9ab
Reviewed-on: https://go-review.googlesource.com/c/tools/+/425095
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
Run-TryBot: Alan Donovan <adonovan@google.com>
Reviewed-by: Tim King <taking@google.com>
2022-11-16 21:35:14 +00:00
..
analysisinternal go/analysis: add Pass.TypeErrors field 2022-11-16 21:35:14 +00:00
apidiff all: gofmt 2022-04-12 17:53:17 +00:00
bug gopls: migrate internal/lsp to gopls/internal/lsp 2022-09-07 16:44:44 +00:00
diff gopls/internal/lsp/source: sort protocol edits 2022-10-11 18:07:12 +00:00
event gopls: migrate internal/lsp to gopls/internal/lsp 2022-09-07 16:44:44 +00:00
facts internal/facts: share go/analysis/internal/facts with gopls 2022-10-25 15:31:58 +00:00
fakenet
fastwalk internal/fastwalk: improve Darwin performance by ~3x 2022-10-13 16:31:57 +00:00
fuzzy gopls/.../fillstruct: support generic types 2022-09-30 19:58:05 +00:00
gcimporter internal/gcimporter: port memory reuse optimizations from Go tree 2022-11-15 20:27:34 +00:00
gocommand go/packages: issue error if 'go list' on PATH is too new 2022-09-28 14:34:08 +00:00
gopathwalk internal/gopathwalk: remove unnecessary call to os.Lstat 2022-03-31 05:33:07 +00:00
goroot go/internal/gcimporter: update to anticipate missing targets and .as 2022-10-26 20:17:01 +00:00
imports internal/imports: repair warnings from default analyzers 2022-10-19 15:24:07 +00:00
jsonrpc2 all: use constant to avoid repeated definitions 2022-09-19 15:32:23 +00:00
jsonrpc2_v2 internal/jsonrpc2_v2: eliminate a potential Accept/Dial race in TestIdleTimeout 2022-11-09 14:00:02 +00:00
memoize internal/memoize: fix race in Store.Promise 2022-07-28 15:35:11 +00:00
packagesinternal x/tools/go/packages: on Go 1.19+, explicitly ask for -json fields needed 2022-04-19 17:08:06 +00:00
persistent internal/persistent: avoid incorrect map validation due to multiple keys 2022-11-08 21:01:57 +00:00
pkgbits internal/pkgbits: port small optimization from compiler to tools 2022-11-15 20:28:31 +00:00
proxydir
stack all: gofmt 2022-04-12 17:53:17 +00:00
testenv go/internal/gcimporter: update to anticipate missing targets and .as 2022-10-26 20:17:01 +00:00
tool internal/tool: implement structured help command 2022-05-04 22:58:41 +00:00
typeparams x/tools/internal/typeparams: use regexp to match wanted result 2022-09-02 19:06:05 +00:00
typesinternal internal/typesinternal: update go/types error codes for 1.20 2022-11-10 22:27:59 +00:00
xcontext