// Copyright 2024 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.package aliasesimport ()// Rhs returns the type on the right-hand side of the alias declaration.func ( *types.Alias) types.Type {if , := any().(interface{ () types.Type }); {return .() // go1.23+ }// go1.22's Alias didn't have the Rhs method, // so Unalias is the best we can do.returntypes.Unalias()}// TypeParams returns the type parameter list of the alias.func ( *types.Alias) *types.TypeParamList {if , := any().(interface{ () *types.TypeParamList }); {return .() // go1.23+ }returnnil}// SetTypeParams sets the type parameters of the alias type.func ( *types.Alias, []*types.TypeParam) {if , := any().(interface { ( []*types.TypeParam) }); { .() // go1.23+ } elseiflen() > 0 {panic("cannot set type parameters of an Alias type in go1.22") }}// TypeArgs returns the type arguments used to instantiate the Alias type.func ( *types.Alias) *types.TypeList {if , := any().(interface{ () *types.TypeList }); {return .() // go1.23+ }returnnil// empty (go1.22)}// Origin returns the generic Alias type of which alias is an instance.// If alias is not an instance of a generic alias, Origin returns alias.func ( *types.Alias) *types.Alias {if , := any().(interface{ () *types.Alias }); {return .() // go1.23+ }return// not an instance of a generic alias (go1.22)}// Enabled reports whether [NewAlias] should create [types.Alias] types.//// This function is expensive! Call it sparingly.func () bool {// The only reliable way to compute the answer is to invoke go/types. // We don't parse the GODEBUG environment variable, because // (a) it's tricky to do so in a manner that is consistent // with the godebug package; in particular, a simple // substring check is not good enough. The value is a // rightmost-wins list of options. But more importantly: // (b) it is impossible to detect changes to the effective // setting caused by os.Setenv("GODEBUG"), as happens in // many tests. Therefore any attempt to cache the result // is just incorrect. := token.NewFileSet() , := parser.ParseFile(, "a.go", "package p; type A = int", parser.SkipObjectResolution) , := new(types.Config).Check("p", , []*ast.File{}, nil) , := .Scope().Lookup("A").Type().(*types.Alias)return}
The pages are generated with Goldsv0.7.6. (GOOS=linux GOARCH=amd64)