Skip to content

Commit 00a7bdc

Browse files
committed
all: delete aliastypeparams GOEXPERIMENT
Always enable aliastypeparams and remove the GOEXPERIMENT. Change-Id: Ic38fe25b0bba312a7f83f7bb94b57ab75ce0f0c3 Reviewed-on: https://go-review.googlesource.com/c/go/+/691956 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Mark Freeman <[email protected]> Reviewed-by: Michael Knyszek <[email protected]>
1 parent 74421a3 commit 00a7bdc

File tree

22 files changed

+19
-76
lines changed

22 files changed

+19
-76
lines changed

src/cmd/compile/internal/noder/unified.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ package noder
77
import (
88
"cmp"
99
"fmt"
10-
"internal/buildcfg"
1110
"internal/pkgbits"
1211
"internal/types/errors"
1312
"io"
@@ -464,11 +463,8 @@ func readPackage(pr *pkgReader, importpkg *types.Pkg, localStub bool) {
464463
// writeUnifiedExport writes to `out` the finalized, self-contained
465464
// Unified IR export data file for the current compilation unit.
466465
func writeUnifiedExport(out io.Writer) {
467-
// Use V2 as the encoded version aliastypeparams GOEXPERIMENT is enabled.
468-
version := pkgbits.V1
469-
if buildcfg.Experiment.AliasTypeParams {
470-
version = pkgbits.V2
471-
}
466+
// Use V2 as the encoded version for aliastypeparams.
467+
version := pkgbits.V2
472468
l := linker{
473469
pw: pkgbits.NewPkgEncoder(version, base.Debug.SyncFrames),
474470

src/cmd/compile/internal/noder/writer.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,8 @@ type pkgWriter struct {
9696
// newPkgWriter returns an initialized pkgWriter for the specified
9797
// package.
9898
func newPkgWriter(m posMap, pkg *types2.Package, info *types2.Info, otherInfo map[*syntax.FuncLit]bool) *pkgWriter {
99-
// Use V2 as the encoded version aliastypeparams GOEXPERIMENT is enabled.
100-
version := pkgbits.V1
101-
if buildcfg.Experiment.AliasTypeParams {
102-
version = pkgbits.V2
103-
}
99+
// Use V2 as the encoded version for aliastypeparams.
100+
version := pkgbits.V2
104101
return &pkgWriter{
105102
PkgEncoder: pkgbits.NewPkgEncoder(version, base.Debug.SyncFrames),
106103

src/cmd/compile/internal/types2/decl.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"cmd/compile/internal/syntax"
99
"fmt"
1010
"go/constant"
11-
"internal/buildcfg"
1211
. "internal/types/errors"
1312
"slices"
1413
)
@@ -525,10 +524,6 @@ func (check *Checker) typeDecl(obj *TypeName, tdecl *syntax.TypeDecl, def *TypeN
525524

526525
// handle type parameters even if not allowed (Alias type is supported)
527526
if tparam0 != nil {
528-
if !versionErr && !buildcfg.Experiment.AliasTypeParams {
529-
check.error(tdecl, UnsupportedFeature, "generic type alias requires GOEXPERIMENT=aliastypeparams")
530-
versionErr = true
531-
}
532527
check.openScope(tdecl, "type parameters")
533528
defer check.closeScope()
534529
check.collectTypeParams(&alias.tparams, tdecl.TParamList)

src/cmd/compile/internal/types2/instantiate.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"cmd/compile/internal/syntax"
1212
"errors"
1313
"fmt"
14-
"internal/buildcfg"
1514
. "internal/types/errors"
1615
)
1716

@@ -130,10 +129,6 @@ func (check *Checker) instance(pos syntax.Pos, orig genericType, targs []Type, e
130129
res = check.newNamedInstance(pos, orig, targs, expanding) // substituted lazily
131130

132131
case *Alias:
133-
if !buildcfg.Experiment.AliasTypeParams {
134-
assert(expanding == nil) // Alias instances cannot be reached from Named types
135-
}
136-
137132
// verify type parameter count (see go.dev/issue/71198 for a test case)
138133
tparams := orig.TypeParams()
139134
if !check.validateTArgLen(pos, orig.obj.Name(), tparams.Len(), len(targs)) {

src/cmd/compile/internal/types2/object_test.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ var testObjects = []struct {
9999
{"type t = struct{f int}", "t", "type p.t = struct{f int}", false},
100100
{"type t = func(int)", "t", "type p.t = func(int)", false},
101101
{"type A = B; type B = int", "A", "type p.A = p.B", true},
102-
{"type A[P ~int] = struct{}", "A", "type p.A[P ~int] = struct{}", true}, // requires GOEXPERIMENT=aliastypeparams
103-
102+
{"type A[P ~int] = struct{}", "A", "type p.A[P ~int] = struct{}", true},
104103
{"var v int", "v", "var p.v int", false},
105104

106105
{"func f(int) string", "f", "func p.f(int) string", false},
@@ -114,10 +113,6 @@ func TestObjectString(t *testing.T) {
114113

115114
for i, test := range testObjects {
116115
t.Run(fmt.Sprint(i), func(t *testing.T) {
117-
if test.alias {
118-
revert := setGOEXPERIMENT("aliastypeparams")
119-
defer revert()
120-
}
121116
src := "package p; " + test.src
122117
conf := Config{Error: func(error) {}, Importer: defaultImporter(), EnableAlias: test.alias}
123118
pkg, err := typecheck(src, &conf, nil)

src/cmd/compile/internal/types2/stdlib_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,8 @@ func TestStdFixed(t *testing.T) {
332332
"issue49814.go", // go/types does not have constraints on array size
333333
"issue56103.go", // anonymous interface cycles; will be a type checker error in 1.22
334334
"issue52697.go", // types2 does not have constraints on stack size
335+
"issue68054.go", // this test requires GODEBUG=gotypesalias=1
336+
"issue68580.go", // this test requires GODEBUG=gotypesalias=1
335337
"issue73309.go", // this test requires GODEBUG=gotypesalias=1
336338
"issue73309b.go", // this test requires GODEBUG=gotypesalias=1
337339

src/go/types/decl.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"go/ast"
1010
"go/constant"
1111
"go/token"
12-
"internal/buildcfg"
1312
. "internal/types/errors"
1413
"slices"
1514
)
@@ -600,10 +599,6 @@ func (check *Checker) typeDecl(obj *TypeName, tdecl *ast.TypeSpec, def *TypeName
600599

601600
// handle type parameters even if not allowed (Alias type is supported)
602601
if tparam0 != nil {
603-
if !versionErr && !buildcfg.Experiment.AliasTypeParams {
604-
check.error(tdecl, UnsupportedFeature, "generic type alias requires GOEXPERIMENT=aliastypeparams")
605-
versionErr = true
606-
}
607602
check.openScope(tdecl, "type parameters")
608603
defer check.closeScope()
609604
check.collectTypeParams(&alias.tparams, tdecl.TypeParams)

src/go/types/instantiate.go

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/go/types/object_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ var testObjects = []struct {
9999
{"type t = struct{f int}", "t", "type p.t = struct{f int}", false},
100100
{"type t = func(int)", "t", "type p.t = func(int)", false},
101101
{"type A = B; type B = int", "A", "type p.A = p.B", true},
102-
{"type A[P ~int] = struct{}", "A", "type p.A[P ~int] = struct{}", true}, // requires GOEXPERIMENT=aliastypeparams
103-
102+
{"type A[P ~int] = struct{}", "A", "type p.A[P ~int] = struct{}", true},
104103
{"var v int", "v", "var p.v int", false},
105104

106105
{"func f(int) string", "f", "func p.f(int) string", false},
@@ -115,8 +114,6 @@ func TestObjectString(t *testing.T) {
115114
for i, test := range testObjects {
116115
t.Run(fmt.Sprint(i), func(t *testing.T) {
117116
if test.alias {
118-
revert := setGOEXPERIMENT("aliastypeparams")
119-
defer revert()
120117
t.Setenv("GODEBUG", "gotypesalias=1")
121118
}
122119

src/go/types/stdlib_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,8 @@ func TestStdFixed(t *testing.T) {
334334
"issue49814.go", // go/types does not have constraints on array size
335335
"issue56103.go", // anonymous interface cycles; will be a type checker error in 1.22
336336
"issue52697.go", // go/types does not have constraints on stack size
337+
"issue68054.go", // this test requires GODEBUG=gotypesalias=1
338+
"issue68580.go", // this test requires GODEBUG=gotypesalias=1
337339
"issue73309.go", // this test requires GODEBUG=gotypesalias=1
338340
"issue73309b.go", // this test requires GODEBUG=gotypesalias=1
339341

0 commit comments

Comments
 (0)