For #70128.
Change-Id: I5949bccbfaaebc435ae8ac7c70580d9740de6f00
Reviewed-on: https://go-review.googlesource.com/c/go/+/652136
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
}
assert(typ.Recv() == nil)
// check iterator argument type
- cb, _ := coreType(typ.Params().At(0).Type()).(*Signature)
+ var cause2 string
+ cb, _ := sharedUnder(check, typ.Params().At(0).Type(), &cause2).(*Signature)
switch {
case cb == nil:
- return bad("func must be func(yield func(...) bool): argument is not func")
+ if cause2 != "" {
+ return bad(check.sprintf("func must be func(yield func(...) bool): in yield type, %s", cause2))
+ } else {
+ return bad("func must be func(yield func(...) bool): argument is not func")
+ }
case cb.Params().Len() > 2:
return bad("func must be func(yield func(...) bool): yield func has too many parameters")
case cb.Results().Len() != 1 || !Identical(cb.Results().At(0).Type(), universeBool):
}
assert(typ.Recv() == nil)
// check iterator argument type
- cb, _ := coreType(typ.Params().At(0).Type()).(*Signature)
+ var cause2 string
+ cb, _ := sharedUnder(check, typ.Params().At(0).Type(), &cause2).(*Signature)
switch {
case cb == nil:
- return bad("func must be func(yield func(...) bool): argument is not func")
+ if cause2 != "" {
+ return bad(check.sprintf("func must be func(yield func(...) bool): in yield type, %s", cause2))
+ } else {
+ return bad("func must be func(yield func(...) bool): argument is not func")
+ }
case cb.Params().Len() > 2:
return bad("func must be func(yield func(...) bool): yield func has too many parameters")
case cb.Results().Len() != 1 || !Identical(cb.Results().At(0).Type(), universeBool):
}
}
+func _[T func() bool | func(int) bool]() {
+ for range func /* ERROR "func must be func(yield func(...) bool): in yield type, func() bool and func(int) bool have different underlying types" */ (T) {} {
+ }
+}
+
// go.dev/issue/65236
func seq0(func() bool) {}