Skip to content

Commit e718aee

Browse files
griesemergopherbot
authored andcommitted
go/types: track gotypesalias non-default behavior
Fixes #66216. Change-Id: I04d7389e5712b35db078844ce424e10f5b96156c Reviewed-on: https://go-review.googlesource.com/c/go/+/579936 Auto-Submit: Robert Griesemer <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Robert Griesemer <[email protected]> Reviewed-by: Robert Findley <[email protected]>
1 parent 9101bf1 commit e718aee

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

src/go/types/decl.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,13 @@ func (check *Checker) typeDecl(obj *TypeName, tdecl *ast.TypeSpec, def *TypeName
607607
alias.fromRHS = rhs
608608
Unalias(alias) // resolve alias.actual
609609
} else {
610+
// With Go1.23, the default behavior is to use Alias nodes,
611+
// reflected by check.enableAlias. Signal non-default behavior.
612+
//
613+
// TODO(gri) Testing runs tests in both modes. Do we need to exclude
614+
// tracking of non-default behavior for tests?
615+
gotypesalias.IncNonDefault()
616+
610617
if !versionErr && tparam0 != nil {
611618
check.error(tdecl, UnsupportedFeature, "generic type alias requires GODEBUG=gotypesalias=1 or unset")
612619
versionErr = true

src/internal/godebugs/table.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var All = []Info{
3030
{Name: "gocachehash", Package: "cmd/go"},
3131
{Name: "gocachetest", Package: "cmd/go"},
3232
{Name: "gocacheverify", Package: "cmd/go"},
33-
{Name: "gotypesalias", Package: "go/types", Changed: 23, Old: "0", Opaque: true}, // bug #66216: remove Opaque
33+
{Name: "gotypesalias", Package: "go/types", Changed: 23, Old: "0"},
3434
{Name: "http2client", Package: "net/http"},
3535
{Name: "http2debug", Package: "net/http", Opaque: true},
3636
{Name: "http2server", Package: "net/http"},

src/runtime/metrics/doc.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,10 @@ Below is the full list of supported metrics, ordered lexicographically.
246246
The number of non-default behaviors executed by the cmd/go
247247
package due to a non-default GODEBUG=gocacheverify=... setting.
248248
249+
/godebug/non-default-behavior/gotypesalias:events
250+
The number of non-default behaviors executed by the go/types
251+
package due to a non-default GODEBUG=gotypesalias=... setting.
252+
249253
/godebug/non-default-behavior/http2client:events
250254
The number of non-default behaviors executed by the net/http
251255
package due to a non-default GODEBUG=http2client=... setting.

0 commit comments

Comments
 (0)