}
if got < want {
- targs = check.infer(ix.Orig, sig.TypeParams().list(), targs, nil, nil, true)
+ targs = check.infer(ix.Orig, sig.TypeParams().list(), targs, nil, nil)
if targs == nil {
// error was already reported
x.mode = invalid
}
// TODO(gri) provide position information for targs so we can feed
// it to the instantiate call for better error reporting
- targs := check.infer(call, sig.TypeParams().list(), targs, sigParams, args, true)
+ targs := check.infer(call, sig.TypeParams().list(), targs, sigParams, args)
if targs == nil {
return // error already reported
}
// 3) Infer type arguments from untyped function arguments.
//
// Constraint type inference is used after each step to expand the set of type arguments.
-//
-// TODO(rfindley): remove the report parameter: is no longer needed.
-func (check *Checker) infer(posn positioner, tparams []*TypeParam, targs []Type, params *Tuple, args []*operand, report bool) (result []Type) {
+func (check *Checker) infer(posn positioner, tparams []*TypeParam, targs []Type, params *Tuple, args []*operand) (result []Type) {
if debug {
defer func() {
assert(result == nil || len(result) == len(tparams))
// If we have type arguments, see how far we get with constraint type inference.
if len(targs) > 0 {
var index int
- targs, index = check.inferB(tparams, targs, report)
+ targs, index = check.inferB(tparams, targs)
if targs == nil || index < 0 {
return targs
}
}
errorf := func(kind string, tpar, targ Type, arg *operand) {
- if !report {
- return
- }
// provide a better error message if we can
targs, index := u.x.types()
if index == 0 {
// See how far we get with constraint type inference.
// Note that even if we don't have any type arguments, constraint type inference
// may produce results for constraints that explicitly specify a type.
- targs, index = check.inferB(tparams, targs, report)
+ targs, index = check.inferB(tparams, targs)
if targs == nil || index < 0 {
return targs
}
}
// Again, follow up with constraint type inference.
- targs, index = check.inferB(tparams, targs, report)
+ targs, index = check.inferB(tparams, targs)
if targs == nil || index < 0 {
return targs
}
// At least one type argument couldn't be inferred.
assert(index >= 0 && targs[index] == nil)
tpar := tparams[index]
- if report {
- check.errorf(posn, _Todo, "cannot infer %s (%v) (%v)", tpar.obj.name, tpar.obj.pos, targs)
- }
+ check.errorf(posn, _Todo, "cannot infer %s (%v) (%v)", tpar.obj.name, tpar.obj.pos, targs)
return nil
}
// first type argument in that list that couldn't be inferred (and thus is nil). If all
// type arguments were inferred successfully, index is < 0. The number of type arguments
// provided may be less than the number of type parameters, but there must be at least one.
-func (check *Checker) inferB(tparams []*TypeParam, targs []Type, report bool) (types []Type, index int) {
+func (check *Checker) inferB(tparams []*TypeParam, targs []Type) (types []Type, index int) {
assert(len(tparams) >= len(targs) && len(targs) > 0)
// Setup bidirectional unification between those structural bounds
sbound := typ.structuralType()
if sbound != nil {
if !u.unify(typ, sbound) {
- if report {
- check.errorf(tpar.obj, _Todo, "%s does not match %s", tpar.obj, sbound)
- }
+ check.errorf(tpar.obj, _Todo, "%s does not match %s", tpar.obj, sbound)
return nil, 0
}
}