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>
import (
"cmp"
"fmt"
- "internal/buildcfg"
"internal/pkgbits"
"internal/types/errors"
"io"
// 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),
// 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),
"cmd/compile/internal/syntax"
"fmt"
"go/constant"
- "internal/buildcfg"
. "internal/types/errors"
"slices"
)
// 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)
"cmd/compile/internal/syntax"
"errors"
"fmt"
- "internal/buildcfg"
. "internal/types/errors"
)
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)) {
{"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},
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)
"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
"go/ast"
"go/constant"
"go/token"
- "internal/buildcfg"
. "internal/types/errors"
"slices"
)
// 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)
"errors"
"fmt"
"go/token"
- "internal/buildcfg"
. "internal/types/errors"
)
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)) {
{"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},
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")
}
"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
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.
+++ /dev/null
-// Code generated by mkconsts.go. DO NOT EDIT.
-
-//go:build !goexperiment.aliastypeparams
-
-package goexperiment
-
-const AliasTypeParams = false
-const AliasTypeParamsInt = 0
+++ /dev/null
-// Code generated by mkconsts.go. DO NOT EDIT.
-
-//go:build goexperiment.aliastypeparams
-
-package goexperiment
-
-const AliasTypeParams = true
-const AliasTypeParamsInt = 1
// 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
-// -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
-// -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
-// -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
-// compile -goexperiment aliastypeparams
+// compile
// Copyright 2024 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// 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 }
// 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 (
-// 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
-// compile -goexperiment aliastypeparams
+// compile
// Copyright 2024 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style