]> Cypherpunks repositories - gostls13.git/commitdiff
all: delete aliastypeparams GOEXPERIMENT
authorCherry Mui <cherryyz@google.com>
Wed, 30 Jul 2025 20:16:48 +0000 (16:16 -0400)
committerCherry Mui <cherryyz@google.com>
Tue, 12 Aug 2025 13:28:26 +0000 (06:28 -0700)
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 <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Mark Freeman <markfreeman@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
22 files changed:
src/cmd/compile/internal/noder/unified.go
src/cmd/compile/internal/noder/writer.go
src/cmd/compile/internal/types2/decl.go
src/cmd/compile/internal/types2/instantiate.go
src/cmd/compile/internal/types2/object_test.go
src/cmd/compile/internal/types2/stdlib_test.go
src/go/types/decl.go
src/go/types/instantiate.go
src/go/types/object_test.go
src/go/types/stdlib_test.go
src/internal/buildcfg/exp.go
src/internal/goexperiment/exp_aliastypeparams_off.go [deleted file]
src/internal/goexperiment/exp_aliastypeparams_on.go [deleted file]
src/internal/goexperiment/flags.go
src/internal/types/testdata/fixedbugs/issue67683.go
src/internal/types/testdata/fixedbugs/issue69576.go
src/internal/types/testdata/spec/typeAliases1.23b.go
test/fixedbugs/issue68054.go
test/fixedbugs/issue68526.dir/a/a.go
test/fixedbugs/issue68526.dir/main.go
test/fixedbugs/issue68526.go
test/fixedbugs/issue68580.go

index 85982d7c189e142082a7a34e06bbd623961a9908..05f4483d0d9f284b57514b768ecf5ca7a5f034f8 100644 (file)
@@ -7,7 +7,6 @@ package noder
 import (
        "cmp"
        "fmt"
-       "internal/buildcfg"
        "internal/pkgbits"
        "internal/types/errors"
        "io"
@@ -464,11 +463,8 @@ func readPackage(pr *pkgReader, importpkg *types.Pkg, localStub bool) {
 // writeUnifiedExport writes to `out` the finalized, self-contained
 // Unified IR export data file for the current compilation unit.
 func writeUnifiedExport(out io.Writer) {
-       // Use V2 as the encoded version aliastypeparams GOEXPERIMENT is enabled.
-       version := pkgbits.V1
-       if buildcfg.Experiment.AliasTypeParams {
-               version = pkgbits.V2
-       }
+       // Use V2 as the encoded version for aliastypeparams.
+       version := pkgbits.V2
        l := linker{
                pw: pkgbits.NewPkgEncoder(version, base.Debug.SyncFrames),
 
index baff0ceea0e931e545fd3ec3649da3b9b99effda..54e5f1ea5f677f68e798ca827d55408a8feb05f2 100644 (file)
@@ -96,11 +96,8 @@ type pkgWriter struct {
 // newPkgWriter returns an initialized pkgWriter for the specified
 // package.
 func newPkgWriter(m posMap, pkg *types2.Package, info *types2.Info, otherInfo map[*syntax.FuncLit]bool) *pkgWriter {
-       // Use V2 as the encoded version aliastypeparams GOEXPERIMENT is enabled.
-       version := pkgbits.V1
-       if buildcfg.Experiment.AliasTypeParams {
-               version = pkgbits.V2
-       }
+       // Use V2 as the encoded version for aliastypeparams.
+       version := pkgbits.V2
        return &pkgWriter{
                PkgEncoder: pkgbits.NewPkgEncoder(version, base.Debug.SyncFrames),
 
index 64047aa84ff42cbf8716e7e3f4ccd1dbb093b5a1..34105816a65af3ad00b1fa8ec1161d164643195a 100644 (file)
@@ -8,7 +8,6 @@ import (
        "cmd/compile/internal/syntax"
        "fmt"
        "go/constant"
-       "internal/buildcfg"
        . "internal/types/errors"
        "slices"
 )
@@ -525,10 +524,6 @@ func (check *Checker) typeDecl(obj *TypeName, tdecl *syntax.TypeDecl, def *TypeN
 
                        // handle type parameters even if not allowed (Alias type is supported)
                        if tparam0 != nil {
-                               if !versionErr && !buildcfg.Experiment.AliasTypeParams {
-                                       check.error(tdecl, UnsupportedFeature, "generic type alias requires GOEXPERIMENT=aliastypeparams")
-                                       versionErr = true
-                               }
                                check.openScope(tdecl, "type parameters")
                                defer check.closeScope()
                                check.collectTypeParams(&alias.tparams, tdecl.TParamList)
index f7346cab46d3e8f52ebefcf90d254cf7b16583b3..1c8c12d07cfafacd534fb15af70afe2aae1faa56 100644 (file)
@@ -11,7 +11,6 @@ import (
        "cmd/compile/internal/syntax"
        "errors"
        "fmt"
-       "internal/buildcfg"
        . "internal/types/errors"
 )
 
@@ -130,10 +129,6 @@ func (check *Checker) instance(pos syntax.Pos, orig genericType, targs []Type, e
                res = check.newNamedInstance(pos, orig, targs, expanding) // substituted lazily
 
        case *Alias:
-               if !buildcfg.Experiment.AliasTypeParams {
-                       assert(expanding == nil) // Alias instances cannot be reached from Named types
-               }
-
                // verify type parameter count (see go.dev/issue/71198 for a test case)
                tparams := orig.TypeParams()
                if !check.validateTArgLen(pos, orig.obj.Name(), tparams.Len(), len(targs)) {
index f19264e4db6d41b039a7c1210b9b341f95639eeb..4f1a653ff3be273e8b55ddc64af711a4a5a8f20c 100644 (file)
@@ -99,8 +99,7 @@ var testObjects = []struct {
        {"type t = struct{f int}", "t", "type p.t = struct{f int}", false},
        {"type t = func(int)", "t", "type p.t = func(int)", false},
        {"type A = B; type B = int", "A", "type p.A = p.B", true},
-       {"type A[P ~int] = struct{}", "A", "type p.A[P ~int] = struct{}", true}, // requires GOEXPERIMENT=aliastypeparams
-
+       {"type A[P ~int] = struct{}", "A", "type p.A[P ~int] = struct{}", true},
        {"var v int", "v", "var p.v int", false},
 
        {"func f(int) string", "f", "func p.f(int) string", false},
@@ -114,10 +113,6 @@ func TestObjectString(t *testing.T) {
 
        for i, test := range testObjects {
                t.Run(fmt.Sprint(i), func(t *testing.T) {
-                       if test.alias {
-                               revert := setGOEXPERIMENT("aliastypeparams")
-                               defer revert()
-                       }
                        src := "package p; " + test.src
                        conf := Config{Error: func(error) {}, Importer: defaultImporter(), EnableAlias: test.alias}
                        pkg, err := typecheck(src, &conf, nil)
index 35e15d814defbb0a180c936605c025ce2e46d828..365bc97462683b1bfba5ce794adcd51cf531da7b 100644 (file)
@@ -332,6 +332,8 @@ func TestStdFixed(t *testing.T) {
                "issue49814.go",  // go/types does not have constraints on array size
                "issue56103.go",  // anonymous interface cycles; will be a type checker error in 1.22
                "issue52697.go",  // types2 does not have constraints on stack size
+               "issue68054.go",  // this test requires GODEBUG=gotypesalias=1
+               "issue68580.go",  // this test requires GODEBUG=gotypesalias=1
                "issue73309.go",  // this test requires GODEBUG=gotypesalias=1
                "issue73309b.go", // this test requires GODEBUG=gotypesalias=1
 
index f40a8e54b9bf136def16ee999ad8e1c16651ab05..42423d291cee8da4e01744270c60a1b1dec4fd62 100644 (file)
@@ -9,7 +9,6 @@ import (
        "go/ast"
        "go/constant"
        "go/token"
-       "internal/buildcfg"
        . "internal/types/errors"
        "slices"
 )
@@ -600,10 +599,6 @@ func (check *Checker) typeDecl(obj *TypeName, tdecl *ast.TypeSpec, def *TypeName
 
                        // handle type parameters even if not allowed (Alias type is supported)
                        if tparam0 != nil {
-                               if !versionErr && !buildcfg.Experiment.AliasTypeParams {
-                                       check.error(tdecl, UnsupportedFeature, "generic type alias requires GOEXPERIMENT=aliastypeparams")
-                                       versionErr = true
-                               }
                                check.openScope(tdecl, "type parameters")
                                defer check.closeScope()
                                check.collectTypeParams(&alias.tparams, tdecl.TypeParams)
index db270eb55634e8d588038dffd0795bde15f90acb..eef473447da414bc2bd19fcf505d825c7569e139 100644 (file)
@@ -14,7 +14,6 @@ import (
        "errors"
        "fmt"
        "go/token"
-       "internal/buildcfg"
        . "internal/types/errors"
 )
 
@@ -133,10 +132,6 @@ func (check *Checker) instance(pos token.Pos, orig genericType, targs []Type, ex
                res = check.newNamedInstance(pos, orig, targs, expanding) // substituted lazily
 
        case *Alias:
-               if !buildcfg.Experiment.AliasTypeParams {
-                       assert(expanding == nil) // Alias instances cannot be reached from Named types
-               }
-
                // verify type parameter count (see go.dev/issue/71198 for a test case)
                tparams := orig.TypeParams()
                if !check.validateTArgLen(pos, orig.obj.Name(), tparams.Len(), len(targs)) {
index 0b4fce7bb161ceabcce2b75f17808b321e05db4f..fc165fb7a0160afd42ad269c3e46cbf19bf7e8dc 100644 (file)
@@ -99,8 +99,7 @@ var testObjects = []struct {
        {"type t = struct{f int}", "t", "type p.t = struct{f int}", false},
        {"type t = func(int)", "t", "type p.t = func(int)", false},
        {"type A = B; type B = int", "A", "type p.A = p.B", true},
-       {"type A[P ~int] = struct{}", "A", "type p.A[P ~int] = struct{}", true}, // requires GOEXPERIMENT=aliastypeparams
-
+       {"type A[P ~int] = struct{}", "A", "type p.A[P ~int] = struct{}", true},
        {"var v int", "v", "var p.v int", false},
 
        {"func f(int) string", "f", "func p.f(int) string", false},
@@ -115,8 +114,6 @@ func TestObjectString(t *testing.T) {
        for i, test := range testObjects {
                t.Run(fmt.Sprint(i), func(t *testing.T) {
                        if test.alias {
-                               revert := setGOEXPERIMENT("aliastypeparams")
-                               defer revert()
                                t.Setenv("GODEBUG", "gotypesalias=1")
                        }
 
index 8e95d23ec38375b0bee23150e97fff2af07d0e33..79ccbc6fcfad92421449f05ac056d02d60555814 100644 (file)
@@ -334,6 +334,8 @@ func TestStdFixed(t *testing.T) {
                "issue49814.go",  // go/types does not have constraints on array size
                "issue56103.go",  // anonymous interface cycles; will be a type checker error in 1.22
                "issue52697.go",  // go/types does not have constraints on stack size
+               "issue68054.go",  // this test requires GODEBUG=gotypesalias=1
+               "issue68580.go",  // this test requires GODEBUG=gotypesalias=1
                "issue73309.go",  // this test requires GODEBUG=gotypesalias=1
                "issue73309b.go", // this test requires GODEBUG=gotypesalias=1
 
index df84e9fdf46feb42e9ad5b44e552bc1a31e0a211..310226bc0146e58914000e3059c3bff07809bde8 100644 (file)
@@ -79,10 +79,9 @@ func ParseGOEXPERIMENT(goos, goarch, goexp string) (*ExperimentFlags, error) {
        dwarf5Supported := (goos != "darwin" && goos != "ios" && goos != "aix")
 
        baseline := goexperiment.Flags{
-               RegabiWrappers:  regabiSupported,
-               RegabiArgs:      regabiSupported,
-               AliasTypeParams: true,
-               Dwarf5:          dwarf5Supported,
+               RegabiWrappers: regabiSupported,
+               RegabiArgs:     regabiSupported,
+               Dwarf5:         dwarf5Supported,
        }
 
        // Start with the statically enabled set of experiments.
diff --git a/src/internal/goexperiment/exp_aliastypeparams_off.go b/src/internal/goexperiment/exp_aliastypeparams_off.go
deleted file mode 100644 (file)
index 620d34e..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-// Code generated by mkconsts.go. DO NOT EDIT.
-
-//go:build !goexperiment.aliastypeparams
-
-package goexperiment
-
-const AliasTypeParams = false
-const AliasTypeParamsInt = 0
diff --git a/src/internal/goexperiment/exp_aliastypeparams_on.go b/src/internal/goexperiment/exp_aliastypeparams_on.go
deleted file mode 100644 (file)
index 8f6872c..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-// Code generated by mkconsts.go. DO NOT EDIT.
-
-//go:build goexperiment.aliastypeparams
-
-package goexperiment
-
-const AliasTypeParams = true
-const AliasTypeParamsInt = 1
index dd7a4f446c1a57ec65dfaec8adf7416dabf7d420..3144d3adfc7aba414e7594d05f9429fcc11b3f1e 100644 (file)
@@ -100,11 +100,6 @@ type Flags struct {
        // inlining phase within the Go compiler.
        NewInliner bool
 
-       // AliasTypeParams enables type parameters for alias types.
-       // Requires that gotypesalias=1 is set with GODEBUG.
-       // This flag will be removed with Go 1.25.
-       AliasTypeParams bool
-
        // Synctest enables the testing/synctest package.
        Synctest bool
 
index f7c9bcdd0114c669cafa27cc3df9b4ab72d0956a..c9ad5f6788bec418c648939d90164cb4fc873671 100644 (file)
@@ -1,4 +1,4 @@
-// -goexperiment=aliastypeparams -gotypesalias=1
+// -gotypesalias=1
 
 // Copyright 2024 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
index 97e03dfab4b2cd06e54676ffb5fb5ea593bac96d..fc436bbfd38424e79a57ab6c52b4ae19353353b4 100644 (file)
@@ -1,4 +1,4 @@
-// -goexperiment=aliastypeparams -gotypesalias=1
+// -gotypesalias=1
 
 // Copyright 2024 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
index c92c3d3a7e0ea93adc27c79b4d01a04c650e44d5..8a09899066fe18f8dd11fe2ab8be7377815af750 100644 (file)
@@ -1,4 +1,4 @@
-// -lang=go1.23 -gotypesalias=1 -goexperiment=aliastypeparams
+// -lang=go1.23 -gotypesalias=1
 
 // Copyright 2024 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
index 5409fc908180031337bc0a30a9f05f254165ddf3..e9f95efa14991e7f5e85e8729af5d0fb28640f39 100644 (file)
@@ -1,4 +1,4 @@
-// compile -goexperiment aliastypeparams
+// compile
 
 // Copyright 2024 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
index 83462c7fb99c86d383d2a2915122886dd7ec5ae6..6249eb59df032b621a679d4093a613364d2699e1 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build goexperiment.aliastypeparams
-
 package a
 
 type A[T any] = struct{ F T }
index 966efd71900234d8a2eca3ba49215c8aeefda0ea..8b72ea37b69ebdf010b9ef9c54fcc04edebb2f6d 100644 (file)
@@ -2,8 +2,6 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build goexperiment.aliastypeparams
-
 package main
 
 import (
index 3067aa76222941b0c17099e8fd9d3b5597287e86..aca6354b7c69486d71222714dc75aeaa4c4e951e 100644 (file)
@@ -1,4 +1,4 @@
-// runindir -goexperiment aliastypeparams -gomodversion "1.23"
+// runindir -gomodversion "1.23"
 
 // Copyright 2024 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
index b60a7447aaa77b5a69f0290893233b00fc356a16..5c25d15b4362d20261d26e58cc467cf414c459d1 100644 (file)
@@ -1,4 +1,4 @@
-// compile -goexperiment aliastypeparams
+// compile
 
 // Copyright 2024 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style