github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/cmd/compile/internal/types2/alias.go (about) 1 // Copyright 2023 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package types2 6 7 // An Alias represents an alias type. 8 // Whether or not Alias types are created is controlled by the 9 // gotypesalias setting with the GODEBUG environment variable. 10 // For gotypesalias=1, alias declarations produce an Alias type. 11 // Otherwise, the alias information is only in the type name, 12 // which points directly to the actual (aliased) type. 13 type Alias struct { 14 obj *TypeName 15 tparams *TypeParamList 16 fromRHS Type 17 actual Type 18 } 19 20 // NewAlias creates a new Alias type with the given type name and rhs. 21 // rhs must not be nil. 22 func NewAlias(obj *TypeName, rhs Type) *Alias 23 24 func (a *Alias) Obj() *TypeName 25 func (a *Alias) Underlying() Type 26 func (a *Alias) String() string 27 28 // Unalias returns t if it is not an alias type; 29 // otherwise it follows t's alias chain until it 30 // reaches a non-alias type which is then returned. 31 // Consequently, the result is never an alias type. 32 func Unalias(t Type) Type