Vague implicit extension

Can someone explain to me why I get here a "divergent implicit extension error"? I think this is due to the type synonym type MyIdType = String, but I'm not sure why.

import org.scalacheck.Arbitrary
import org.scalacheck.Arbitrary._
import org.scalacheck.Gen

def arbitraryCaseClass[A,C](f: A => C)(implicit t: Arbitrary[A]): Arbitrary[C] = Arbitrary(for(v <- arbitrary[A]) yield f(v))

type MyIdType = String

implicit val arbMyIdType: Arbitrary[MyIdType] = Arbitrary(Gen.identifier)

case class Foo(s: MyIdType, t: Int)

implicit def arbA = arbitraryCaseClass((Foo.apply _).tupled)

val foo = arbitrary[Foo].sample

Error:

Error:(13, 40) diverging implicit expansion for type org.scalacheck.Arbitrary[(A$A6.this.MyIdType, Int)]
starting with method arbTuple2 in trait ArbitraryArities
implicit def arbA = arbitraryCaseClass((Foo.apply _).tupled)
+4
source share

All Articles