github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/cmd/compile/internal/types2/union.go (about) 1 // Copyright 2021 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 // A Union represents a union of terms embedded in an interface. 8 type Union struct { 9 terms []*Term 10 } 11 12 // NewUnion returns a new Union type with the given terms. 13 // It is an error to create an empty union; they are syntactically not possible. 14 func NewUnion(terms []*Term) *Union 15 16 func (u *Union) Len() int 17 func (u *Union) Term(i int) *Term 18 19 func (u *Union) Underlying() Type 20 func (u *Union) String() string 21 22 // A Term represents a term in a Union. 23 type Term term 24 25 // NewTerm returns a new union term. 26 func NewTerm(tilde bool, typ Type) *Term 27 28 func (t *Term) Tilde() bool 29 func (t *Term) Type() Type 30 func (t *Term) String() string