-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
Showing
14 changed files
with
80 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,14 @@ | ||
module golang.org/x/tools | ||
|
||
go 1.19 | ||
go 1.19 // => default GODEBUG has gotypesalias=0 | ||
|
||
require ( | ||
github.com/google/go-cmp v0.6.0 | ||
github.com/yuin/goldmark v1.4.13 | ||
golang.org/x/mod v0.17.0 | ||
golang.org/x/net v0.24.0 | ||
) | ||
|
||
require golang.org/x/sync v0.7.0 | ||
|
||
require github.com/google/go-cmp v0.6.0 // indirect | ||
|
||
require ( | ||
golang.org/x/sys v0.19.0 // indirect | ||
golang.org/x/sync v0.7.0 | ||
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2 | ||
) | ||
|
||
require golang.org/x/sys v0.19.0 // indirect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters