// funcInst type-checks a function instantiation. // The incoming x must be a generic function. // If inst != nil, it provides some or all of the type arguments (inst.Index). // If target != nil, it may be used to infer missing type arguments of x, if any. // At least one of T or inst must be provided. // // There are two modes of operation: // // 1. If infer == true, funcInst infers missing type arguments as needed and // instantiates the function x. The returned results are nil. // // 2. If infer == false and inst provides all type arguments, funcInst // instantiates the function x. The returned results are nil. // If inst doesn't provide enough type arguments, funcInst returns the // available arguments and the corresponding expression list; x remains // unchanged. // // If an error (other than a version error) occurs in any case, it is reported // and x.mode is set to invalid. func (check *Checker) funcInst(T *target, pos syntax.Pos, x *operand, inst *syntax.IndexExpr, infer bool) ([]Type, []syntax.Expr) { … } func (check *Checker) instantiateSignature(pos syntax.Pos, expr syntax.Expr, typ *Signature, targs []Type, xlist []syntax.Expr) (res *Signature) { … } func (check *Checker) callExpr(x *operand, call *syntax.CallExpr) exprKind { … } // exprList evaluates a list of expressions and returns the corresponding operands. // A single-element expression list may evaluate to multiple operands. func (check *Checker) exprList(elist []syntax.Expr) (xlist []*operand) { … } // genericExprList is like exprList but result operands may be uninstantiated or partially // instantiated generic functions (where constraint information is insufficient to infer // the missing type arguments) for Go 1.21 and later. // For each non-generic or uninstantiated generic operand, the corresponding targsList and // xlistList elements do not exist (targsList and xlistList are nil) or the elements are nil. // For each partially instantiated generic function operand, the corresponding targsList and // xlistList elements are the operand's partial type arguments and type expression lists. func (check *Checker) genericExprList(elist []syntax.Expr) (resList []*operand, targsList [][]Type, xlistList [][]syntax.Expr) { … } // arguments type-checks arguments passed to a function call with the given signature. // The function and its arguments may be generic, and possibly partially instantiated. // targs and xlist are the function's type arguments (and corresponding expressions). // args are the function arguments. If an argument args[i] is a partially instantiated // generic function, atargs[i] and atxlist[i] are the corresponding type arguments // (and corresponding expressions). // If the callee is variadic, arguments adjusts its signature to match the provided // arguments. The type parameters and arguments of the callee and all its arguments // are used together to infer any missing type arguments, and the callee and argument // functions are instantiated as necessary. // The result signature is the (possibly adjusted and instantiated) function signature. // If an error occurred, the result signature is the incoming sig. func (check *Checker) arguments(call *syntax.CallExpr, sig *Signature, targs []Type, xlist []syntax.Expr, args []*operand, atargs [][]Type, atxlist [][]syntax.Expr) (rsig *Signature) { … } var cgoPrefixes … func (check *Checker) selector(x *operand, e *syntax.SelectorExpr, def *TypeName, wantType bool) { … } // use type-checks each argument. // Useful to make sure expressions are evaluated // (and variables are "used") in the presence of // other errors. Arguments may be nil. // Reports if all arguments evaluated without error. func (check *Checker) use(args ...syntax.Expr) bool { … } // useLHS is like use, but doesn't "use" top-level identifiers. // It should be called instead of use if the arguments are // expressions on the lhs of an assignment. func (check *Checker) useLHS(args ...syntax.Expr) bool { … } func (check *Checker) useN(args []syntax.Expr, lhs bool) bool { … } func (check *Checker) use1(e syntax.Expr, lhs bool) bool { … }