package aliases
import "golang.org/x/tools/internal/aliases"
Index ¶
- func Enabled() bool
- func NewAlias(enabled bool, pos token.Pos, pkg *types.Package, name string, rhs types.Type, tparams []*types.TypeParam) *types.TypeName
- func Origin(alias *types.Alias) *types.Alias
- func Rhs(alias *types.Alias) types.Type
- func SetTypeParams(alias *types.Alias, tparams []*types.TypeParam)
- func TypeArgs(alias *types.Alias) *types.TypeList
- func TypeParams(alias *types.Alias) *types.TypeParamList
Functions ¶
func Enabled ¶
func Enabled() bool
Enabled reports whether NewAlias should create types.Alias types.
This function is expensive! Call it sparingly.
func NewAlias ¶
func NewAlias(enabled bool, pos token.Pos, pkg *types.Package, name string, rhs types.Type, tparams []*types.TypeParam) *types.TypeName
NewAlias creates a new TypeName in Package pkg that is an alias for the type rhs.
The enabled parameter determines whether the resulting [TypeName]'s type is an types.Alias. Its value must be the result of a call to Enabled, which computes the effective value of GODEBUG=gotypesalias=... by invoking the type checker. The Enabled function is expensive and should be called once per task (e.g. package import), not once per call to NewAlias.
Precondition: enabled || len(tparams)==0. If materialized aliases are disabled, there must not be any type parameters.
func Origin ¶
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 Rhs ¶
Rhs returns the type on the right-hand side of the alias declaration.
func SetTypeParams ¶
SetTypeParams sets the type parameters of the alias type.
func TypeArgs ¶
TypeArgs returns the type arguments used to instantiate the Alias type.
func TypeParams ¶
func TypeParams(alias *types.Alias) *types.TypeParamList
TypeParams returns the type parameter list of the alias.
Source Files ¶
aliases.go aliases_go122.go
- Version
- v0.30.0 (latest)
- Published
- Feb 10, 2025
- Platform
- linux/amd64
- Imports
- 4 packages
- Last checked
- 8 hours ago –
Tools for package owners.