mirror of
https://github.com/golang/go
synced 2024-11-15 00:30:31 -07:00
go/types, types2: use GOEXPERIMENT to enable alias type parameters
For #46477. Change-Id: Ia3558f9d2bf43fdd9e3618bd9f800d268e13b367 Reviewed-on: https://go-review.googlesource.com/c/go/+/586956 Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Robert Griesemer <gri@google.com>
This commit is contained in:
parent
c3591cb30c
commit
d68d485405
@ -8,6 +8,7 @@ import (
|
||||
"cmd/compile/internal/syntax"
|
||||
"fmt"
|
||||
"go/constant"
|
||||
"internal/buildcfg"
|
||||
. "internal/types/errors"
|
||||
)
|
||||
|
||||
@ -522,6 +523,10 @@ 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)
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
"go/ast"
|
||||
"go/constant"
|
||||
"go/token"
|
||||
"internal/buildcfg"
|
||||
. "internal/types/errors"
|
||||
)
|
||||
|
||||
@ -597,6 +598,10 @@ 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)
|
||||
|
@ -1,4 +1,4 @@
|
||||
// -lang=go1.23 -gotypesalias=1
|
||||
// -lang=go1.23 -gotypesalias=1 -goexperiment=aliastypeparams
|
||||
|
||||
// Copyright 2024 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
|
Loading…
Reference in New Issue
Block a user