diff --git a/.scalafmt.conf b/.scalafmt.conf index 4d63407c24..2260d0ea0d 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -10,3 +10,8 @@ align.preset = some spaces.inByNameTypes = false project.excludePaths = ["glob:**/guide/**/*.scala"] + +project.excludeFilters = [ + "org.specs2.matcher.describe.DiffableLowImplicits2", + "org.specs2.matcher.describe.DiffableSpec", +] diff --git a/matcher/shared/src/main/scala/org/specs2/matcher/describe/Diffable.scala b/matcher/shared/src/main/scala/org/specs2/matcher/describe/Diffable.scala index 0d3a140bf2..f270a90ca5 100644 --- a/matcher/shared/src/main/scala/org/specs2/matcher/describe/Diffable.scala +++ b/matcher/shared/src/main/scala/org/specs2/matcher/describe/Diffable.scala @@ -78,7 +78,12 @@ trait DiffableLowImplicits2 extends DiffableLowImplicits3: inline def summonAll[T <: Tuple]: List[Diffable[?]] = inline erasedValue[T] match case _: EmptyTuple => Nil - case _: (t *: ts) => summonInline[Diffable[t]] :: summonAll[ts] + // in the case of a large number of fields we summon the diffables 5 by 5 in order + // to avoid hitting the max inlining limit of 32 by default + case _: (t1 *: t2 *: t3 *: t4 *: t5 *: ts) => + summonInline[Diffable[t1]] :: summonInline[Diffable[t2]] :: summonInline[Diffable[t3]] :: + summonInline[Diffable[t4]] :: summonInline[Diffable[t5]] :: summonAll[ts] + case _: (t *: ts) => summonInline[Diffable[t]] :: summonAll[ts] trait DiffableLowImplicits3: diff --git a/tests/shared/src/test/scala/org/specs2/matcher/describe/DiffableSpec.scala b/tests/shared/src/test/scala/org/specs2/matcher/describe/DiffableSpec.scala index e3cb280f95..0b18816534 100644 --- a/tests/shared/src/test/scala/org/specs2/matcher/describe/DiffableSpec.scala +++ b/tests/shared/src/test/scala/org/specs2/matcher/describe/DiffableSpec.scala @@ -265,6 +265,15 @@ Compare result Failure[String](ex2) ) must ===(TryTypeDifferent(isActualSuccess = true))} + Inlining limit + ============== + + Taking the diff of a large case class must not reach the inlining limit ${ + val largeCase = + LargeClass("", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", Nested("", "", "", "", "", "")) + + largeCase must beEqualTo(largeCase) + } """ @@ -297,3 +306,37 @@ Compare result sealed trait Animal case class Cat() extends Animal case class Dog() extends Animal + +case class LargeClass( + a1: String, + a2: String, + a3: String, + a4: String, + a5: String, + a6: String, + a7: String, + a8: String, + a9: String, + a10: String, + a11: String, + a12: String, + a13: String, + a14: String, + a15: String, + a16: String, + a17: String, + a18: String, + a19: String, + a20: String, + a21: String, + a22: Nested +) + +case class Nested( + a23: String, + a24: String, + a25: String, + a26: String, + a27: String, + a28: String +)