зеркало из https://github.com/golang/tools.git
440f3c37e4
The predicate that determines whether the type checker creates types.Alias nodes is complex: it depends on an environment variable (GODEBUG) that is somewhat tricky to parse correctly, since it is a rightmost-wins list. Critically, however, its default value is a function of the go directive in the application's go.mod file, which is inaccessible to logic in x/tools (per-file build tags can detect the toolchain version, but not the go.mod version). Equally critically, the current effective value of the gotypesalias variable changes when os.Setenv(GODEBUG) is called, which happens in tests, and there is no way to detect those events; therefore any attempt to cache the value is wrong. This change exposes a simplified version of the Enabled function from aliases, which always computes the ground truth by invoking the type checker, regardless of cost. It also adds an 'enabled' parameter to NewAlias so that callers can amortize this cost. Also, various minor cleanups related to aliases. Updates golang/go#64581 Change-Id: If926edefb8e1c1f63c17e4fad0a808e27bac6d5b Reviewed-on: https://go-review.googlesource.com/c/tools/+/580455 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Robert Findley <rfindley@google.com> |
||
---|---|---|
.. | ||
exec.go | ||
testenv.go | ||
testenv_notunix.go | ||
testenv_unix.go |