tools/internal/typesinternal
Alan Donovan bfc94c967a go/ssa: extract type recursion into a helper package
This change moves ssa.forEachReachable into
internal/typesinternal.ForEachElement, simplifies
the signature (by internalizing the type map part)
and adds a test.

There are two copies of this algorithm (the other in
go/callgraph/rta), and we will need it again in
ssautil.Reachable (see golang/go#69291).
A follow-up change will make the copy in rta delegate
to this one (small steps).

Also, make ssa.Program.RuntimeTypes do the type analysis
when it is called, instead of doing it eagerly each time
we encounter a MakeInterface instruction.
This should reduce eventually costs since RuntimeTypes
shouldn't be needed: it was added for the pointer analysis
(since deleted) and it used by ssautil.AllFunctions (to
be replaced, see golang/go#69291), and in both cases it
is the wrong tool for the job because:

(a) it is more precise to accumulate runtime types in
    the subset of the program of interest, while doing
    some kind of reachability fixed-point computation;
    and

(b) its use in AllFunctions is unsound because although
    it accounts for all (too many!) MakeInterface operations
    it does not account for types exposed through public
    API (see the proposed replacement, ssautil.Reachable)
    when analyzing incomplete programs.

Updates golang/go#69291

Change-Id: Ib369278e50295b9287fe95c06169b81425193e90
Reviewed-on: https://go-review.googlesource.com/c/tools/+/610939
Reviewed-by: Tim King <taking@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-09-09 20:13:36 +00:00
..
element.go go/ssa: extract type recursion into a helper package 2024-09-09 20:13:36 +00:00
element_test.go go/ssa: extract type recursion into a helper package 2024-09-09 20:13:36 +00:00
errorcode.go internal/typesinternal: correct spec anchors in comments 2024-09-04 14:10:57 +00:00
errorcode_string.go internal/typesinternal: update go/types error codes for 1.20 2022-11-10 22:27:59 +00:00
errorcode_test.go internal/typesinternal: update go/types error codes for 1.20 2022-11-10 22:27:59 +00:00
recv.go gopls: rationalize "deref" helpers 2024-02-22 18:17:25 +00:00
toonew.go gopls/internal/analysis/stdversion: set RunDespiteErrors 2024-03-08 23:48:57 +00:00
types.go gopls/internal/analysis/fillstruct: use package name (not path) in UI 2024-06-27 18:36:39 +00:00