Closed
Description
https://github.com/xuwei-k/apply-overload-2.11.9
import org.scalacheck.{Arbitrary, Gen}
case class Foo[A](x: Option[Int], y: A)
object Foo {
// error
implicit def arbitrary[A](implicit a: Arbitrary[A]): Arbitrary[Foo[A]] =
Arbitrary(Gen.resultOf[Option[Int], A, Foo[A]](Foo.apply[A]))
def apply[A](x: Int, y: A): Foo[A] = Foo(Some(x), y)
}
[error] found : (Int, A) => example.Foo[A]
[error] required: (Option[Int], A) => example.Foo[A]
[error] Arbitrary(Gen.resultOf[Option[Int], A, Foo[A]](Foo.apply[A]))
[error] ^
but this is ok (change method definition order)
object Foo {
def apply[A](x: Int, y: A): Foo[A] = Foo(Some(x), y)
// ok
implicit def arbitrary[A](implicit a: Arbitrary[A]): Arbitrary[Foo[A]] =
Arbitrary(Gen.resultOf[Option[Int], A, Foo[A]](Foo.apply[A]))
}
Metadata
Metadata
Assignees
Labels
No labels