// If we have type arguments, see how far we get with constraint type inference.
if len(targs) > 0 && useConstraintTypeInference {
var index int
- targs, index = check.inferB(tparams, targs)
+ targs, index = check.inferB(pos, tparams, targs)
if targs == nil || index < 0 {
return targs
}
// Note that even if we don't have any type arguments, constraint type inference
// may produce results for constraints that explicitly specify a type.
if useConstraintTypeInference {
- targs, index = check.inferB(tparams, targs)
+ targs, index = check.inferB(pos, tparams, targs)
if targs == nil || index < 0 {
return targs
}
// Again, follow up with constraint type inference.
if useConstraintTypeInference {
- targs, index = check.inferB(tparams, targs)
+ targs, index = check.inferB(pos, tparams, targs)
if targs == nil || index < 0 {
return targs
}
// 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) (types []Type, index int) {
+func (check *Checker) inferB(pos syntax.Pos, tparams []*TypeParam, targs []Type) (types []Type, index int) {
assert(len(tparams) >= len(targs) && len(targs) > 0)
// Setup bidirectional unification between constraints
if !u.unify(tpar, sbound) {
// TODO(gri) improve error message by providing the type arguments
// which we know already
- check.errorf(tpar.obj, "%s does not match %s", tpar, sbound)
+ check.errorf(pos, "%s does not match %s", tpar, sbound)
return nil, 0
}
}
package issue45985
-// TODO(gri): this error should be on app[int] below.
-func app[S /* ERROR "S does not match" */ interface{ ~[]T }, T any](s S, e T) S {
+func app[S interface{ ~[]T }, T any](s S, e T) S {
return append(s, e)
}
func _() {
- _ = app[int]
+ _ = app[/* ERROR "S does not match" */int]
}
// 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)
+ targs, index = check.inferB(posn, tparams, targs)
if targs == nil || index < 0 {
return targs
}
// 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)
+ targs, index = check.inferB(posn, tparams, targs)
if targs == nil || index < 0 {
return targs
}
}
// Again, follow up with constraint type inference.
- targs, index = check.inferB(tparams, targs)
+ targs, index = check.inferB(posn, tparams, targs)
if targs == nil || index < 0 {
return targs
}
// 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) (types []Type, index int) {
+func (check *Checker) inferB(posn positioner, tparams []*TypeParam, targs []Type) (types []Type, index int) {
assert(len(tparams) >= len(targs) && len(targs) > 0)
// Setup bidirectional unification between constraints
if !u.unify(tpar, sbound) {
// TODO(gri) improve error message by providing the type arguments
// which we know already
- check.errorf(tpar.obj, _InvalidTypeArg, "%s does not match %s", tpar, sbound)
+ check.errorf(posn, _InvalidTypeArg, "%s does not match %s", tpar, sbound)
return nil, 0
}
}
package issue45985
-// TODO(rFindley): this error should be on app[int] below.
-func app[S /* ERROR "S does not match" */ interface{ ~[]T }, T any](s S, e T) S {
+func app[S interface{ ~[]T }, T any](s S, e T) S {
return append(s, e)
}
func _() {
- _ = app[int]
+ _ = app/* ERROR "S does not match" */[int]
}