"cmd/compile/internal/syntax"
"cmd/compile/internal/types2"
"cmd/internal/src"
- "internal/godebug"
"internal/pkgbits"
)
type pkgReader struct {
pkgbits.PkgDecoder
- ctxt *types2.Context
- imports map[string]*types2.Package
+ ctxt *types2.Context
+ imports map[string]*types2.Package
+ enableAlias bool // whether to use aliases
posBases []*syntax.PosBase
pkgs []*types2.Package
ctxt: ctxt,
imports: imports,
+ // Currently, the compiler panics when using Alias types.
+ // TODO(gri) set to true once this is fixed (issue #66873)
+ enableAlias: false,
posBases: make([]*syntax.PosBase, input.NumElems(pkgbits.RelocPosBase)),
pkgs: make([]*types2.Package, input.NumElems(pkgbits.RelocPkg)),
case pkgbits.ObjAlias:
pos := r.pos()
typ := r.typ()
- return newAliasTypeName(pos, objPkg, objName, typ)
+ return newAliasTypeName(pr.enableAlias, pos, objPkg, objName, typ)
case pkgbits.ObjConst:
pos := r.pos()
}
// newAliasTypeName returns a new TypeName, with a materialized *types2.Alias if supported.
-func newAliasTypeName(pos syntax.Pos, pkg *types2.Package, name string, rhs types2.Type) *types2.TypeName {
+func newAliasTypeName(aliases bool, pos syntax.Pos, pkg *types2.Package, name string, rhs types2.Type) *types2.TypeName {
// Copied from x/tools/internal/aliases.NewAlias via
// GOROOT/src/go/internal/gcimporter/ureader.go.
- if gotypesalias.Value() == "1" {
+ if aliases {
tname := types2.NewTypeName(pos, pkg, name, nil)
_ = types2.NewAlias(tname, rhs) // form TypeName -> Alias cycle
return tname
}
return types2.NewTypeName(pos, pkg, name, rhs)
}
-
-// gotypesalias controls the use of Alias types.
-var gotypesalias = godebug.New("#gotypesalias")
"cmd/compile/internal/syntax"
"fmt"
"go/constant"
- "internal/godebug"
. "internal/types/errors"
"sync/atomic"
)
// debugging/development support
const debug = false // leave on during development
-// gotypesalias controls the use of Alias types.
-// As of Apr 16 2024 they are used by default.
-// To disable their use, set GODEBUG to gotypesalias=0.
-// This GODEBUG flag will be removed in the near future (tentatively Go 1.24).
-var gotypesalias = godebug.New("gotypesalias")
-
// _aliasAny changes the behavior of [Scope.Lookup] for "any" in the
// [Universe] scope.
//