I'm facing the same issue as @hejfelix, while using implicitly[Arbitrary[BigCaseClass]].arbitrary:
Could not write class xxx because it exceeds JVM code size limits. Method inst$macro$135$lzycompute's code too large!
The case class has 130 fields.
Any workaround to solve this issue? Thanks!
I found a workaround using generics and implicit generators:
// primitive generators implicit def stringGen(implicit arbString: Arbitrary[String]): Gen[String] = arbString.arbitrary implicit def intGen(implicit arbInt: Arbitrary[Int]): Gen[Int] = arbInt.arbitrary // hlist generator implicit def hnilGen: Gen[HNil] = Gen.const(HNil) implicit def hlistGen[H, T <: HList](implicit headGen: Gen[H], tailGen: Gen[T]) = headGen.flatMap(head => tailGen.map(tail => head :: tail)) // case class generator implicit def caseClassGen[T, L <: HList](implicit generic: Generic.Aux[T, L], lGen: Gen[L]): Gen[T] = lGen.map(generic.from) def generator[A](implicit gen: Gen[A]): Gen[A] = gen
Then you can generate arbitrary big case classes like this:
implicit val generic = Generic[YourBigCaseClass] val gen = generator[YourBigCaseClass] val sample = Gen.nonEmptyListOf(gen).sample.get
I hope that helps anyone facing this limitation.
ShrinkLowPrioritytrait but it seems to conflict with the internals of scalacheck-shapeless. I get
Error:(27, 88) ambiguous implicit values: both method derivedShrink in trait DerivedInstances of type [T](implicit ev: shapeless.LowPriority.Ignoring[String("shrinkAny")], implicit underlying: shapeless.Strict[org.scalacheck.derive.MkShrink[T]])org.scalacheck.Shrink[T] and method shrinkAny in trait ShrinkLowPriority of type [T]=> org.scalacheck.Shrink[T] match expected type ...
Looking at the source there is a
implicit def derivedShrink[T] (implicit ev: LowPriority.Ignoring[Witness.`"shrinkAny"`.T], underlying: Strict[MkShrink[T]] ): Shrink[T] = underlying.value.shrink
But I don't understand what it does.
Hello, can scalacheck-shapeless work with case classes with in turn have fields like Instant / Date / Curency / scala enumeratum, if there are "manual" arbitraries provided for these ?
I can't seem to make it work
the closest i get is to a
scala.UninitializedFieldError: Uninitialized field
edit: it works just have to have all the implicit imports near