go/src/cmd/compile/internal/types2/subst.go

type substMap

// makeSubstMap creates a new substitution map mapping tpars[i] to targs[i].
// If targs[i] is nil, tpars[i] is not substituted.
func makeSubstMap(tpars []*TypeParam, targs []Type) substMap {}

// makeRenameMap is like makeSubstMap, but creates a map used to rename type
// parameters in from with the type parameters in to.
func makeRenameMap(from, to []*TypeParam) substMap {}

func (m substMap) empty() bool {}

func (m substMap) lookup(tpar *TypeParam) Type {}

// subst returns the type typ with its type parameters tpars replaced by the
// corresponding type arguments targs, recursively. subst doesn't modify the
// incoming type. If a substitution took place, the result type is different
// from the incoming type.
//
// If expanding is non-nil, it is the instance type currently being expanded.
// One of expanding or ctxt must be non-nil.
func (check *Checker) subst(pos syntax.Pos, typ Type, smap substMap, expanding *Named, ctxt *Context) Type {}

type subster

func (subst *subster) typ(typ Type) Type {}

// typOrNil is like typ but if the argument is nil it is replaced with Typ[Invalid].
// A nil type may appear in pathological cases such as type T[P any] []func(_ T([]_))
// where an array/slice element is accessed before it is set up.
func (subst *subster) typOrNil(typ Type) Type {}

func (subst *subster) var_(v *Var) *Var {}

func cloneVar(v *Var, typ Type) *Var {}

func (subst *subster) tuple(t *Tuple) *Tuple {}

// substList applies subst to each element of the incoming slice.
// If at least one element changes, the result is a new slice with
// all the (possibly updated) elements of the incoming slice;
// otherwise the result it nil. The incoming slice is unchanged.
func substList[T comparable](in []T, subst func(T) T) (out []T) {}

func (subst *subster) func_(f *Func) *Func {}

func cloneFunc(f *Func, typ Type) *Func {}

func (subst *subster) term(t *Term) *Term {}

// replaceRecvType updates any function receivers that have type old to have
// type new. It does not modify the input slice; if modifications are required,
// the input slice and any affected signatures will be copied before mutating.
//
// The resulting out slice contains the updated functions, and copied reports
// if anything was modified.
func replaceRecvType(in []*Func, old, new Type) (out []*Func, copied bool) {}