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

const unificationDepthLimit

const panicAtUnificationDepthLimit

const enableCoreTypeUnification

const traceInference

type unifier

// newUnifier returns a new unifier initialized with the given type parameter
// and corresponding type argument lists. The type argument list may be shorter
// than the type parameter list, and it may contain nil types. Matching type
// parameters and arguments must have the same index.
func newUnifier(tparams []*TypeParam, targs []Type, enableInterfaceInference bool) *unifier {}

type unifyMode

const assign

const exact

func (m unifyMode) String() string {}

// unify attempts to unify x and y and reports whether it succeeded.
// As a side-effect, types may be inferred for type parameters.
// The mode parameter controls how types are compared.
func (u *unifier) unify(x, y Type, mode unifyMode) bool {}

func (u *unifier) tracef(format string, args ...interface{}

// String returns a string representation of the current mapping
// from type parameters to types.
func (u *unifier) String() string {}

type typeParamsById

func (s typeParamsById) Len() int           {}

func (s typeParamsById) Less(i, j int) bool {}

func (s typeParamsById) Swap(i, j int)      {}

// join unifies the given type parameters x and y.
// If both type parameters already have a type associated with them
// and they are not joined, join fails and returns false.
func (u *unifier) join(x, y *TypeParam) bool {}

// asBoundTypeParam returns x.(*TypeParam) if x is a type parameter recorded with u.
// Otherwise, the result is nil.
func (u *unifier) asBoundTypeParam(x Type) *TypeParam {}

// setHandle sets the handle for type parameter x
// (and all its joined type parameters) to h.
func (u *unifier) setHandle(x *TypeParam, h *Type) {}

// at returns the (possibly nil) type for type parameter x.
func (u *unifier) at(x *TypeParam) Type {}

// set sets the type t for type parameter x;
// t must not be nil.
func (u *unifier) set(x *TypeParam, t Type) {}

// unknowns returns the number of type parameters for which no type has been set yet.
func (u *unifier) unknowns() int {}

// inferred returns the list of inferred types for the given type parameter list.
// The result is never nil and has the same length as tparams; result types that
// could not be inferred are nil. Corresponding type parameters and result types
// have identical indices.
func (u *unifier) inferred(tparams []*TypeParam) []Type {}

// asInterface returns the underlying type of x as an interface if
// it is a non-type parameter interface. Otherwise it returns nil.
func asInterface(x Type) (i *Interface) {}

// nify implements the core unification algorithm which is an
// adapted version of Checker.identical. For changes to that
// code the corresponding changes should be made here.
// Must not be called directly from outside the unifier.
func (u *unifier) nify(x, y Type, mode unifyMode, p *ifacePair) (result bool) {}