After upgrading to scalacheck 1.13.3
, I'm running into an odd issue where deriving instances of A => B Or C
, where Or
is essentially a light Either
, will almost always fail.
This is the simplest code I could write to reproduce the issue:
import org.scalatest.FunSuite
import org.scalatest.prop.GeneratorDrivenPropertyChecks
import org.scalacheck.Shapeless._
class Testor extends FunSuite with GeneratorDrivenPropertyChecks {
sealed trait Or[+A, +B] extends Product with Serializable
case class Left[A](a: A) extends Or[A, Nothing]
case class Right[B](b: B) extends Or[Nothing, B]
test("reproduce") {
forAll { (i: Int, f: Int ⇒ Float Or Boolean) ⇒
f(i)
}
}
}
This fails with:
RetrievalError was thrown during property evaluation.
Message: couldn't generate value
Occurred when passed generated values (
arg0 = 0, // 30 shrinks
arg1 = <function1>
)
Note that providing an explicit Arbitrary[Float Or Boolean]
solves the issue, so it seems pretty clear that the issue is in the generic derivation.
I'm not convinced the problem lies with shapeless-scalacheck
- I tried writing my own generic derivation to see if it helped, and it failed in exactly the same way.
Something weird, but which is probably due to the way arbitrary functions work, is that the function is actually generated, but fails when evaluated.
Would appreciate any help / suggestion with this, as I'm kind of stuck.