1 // Code generated by "go test -run=Generate -write=all"; DO NOT EDIT.
3 // Copyright 2023 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
11 // Names starting with a _ are intended to be exported eventually
12 // (go.dev/issue/63223).
14 // An _Alias represents an alias type.
16 obj *TypeName // corresponding declared alias object
17 fromRHS Type // RHS of type alias declaration; may be an alias
18 actual Type // actual (aliased) type; never an alias
21 // _NewAlias creates a new Alias type with the given type name and rhs.
22 // rhs must not be nil.
23 func _NewAlias(obj *TypeName, rhs Type) *_Alias {
24 return (*Checker)(nil).newAlias(obj, rhs)
27 func (a *_Alias) Underlying() Type { return a.actual.Underlying() }
28 func (a *_Alias) String() string { return TypeString(a, nil) }
32 // _Unalias returns t if it is not an alias type;
33 // otherwise it follows t's alias chain until it
34 // reaches a non-alias type which is then returned.
35 // Consequently, the result is never an alias type.
36 func _Unalias(t Type) Type {
37 if a0, _ := t.(*_Alias); a0 != nil {
49 panic(fmt.Sprintf("non-terminated alias %s", a0.obj.name))
56 // asNamed returns t as *Named if that is t's
57 // actual type. It returns nil otherwise.
58 func asNamed(t Type) *Named {
59 n, _ := _Unalias(t).(*Named)
63 // newAlias creates a new Alias type with the given type name and rhs.
64 // rhs must not be nil.
65 func (check *Checker) newAlias(obj *TypeName, rhs Type) *_Alias {
67 a := &_Alias{obj, rhs, nil}
72 // Ensure that a.actual is set at the end of type checking.
80 func (a *_Alias) cleanup() {