From bd95b11056cf993451472498684ca703c2f68e27 Mon Sep 17 00:00:00 2001 From: kenji yoshida <6b656e6a69@gmail.com> Date: Sun, 28 Apr 2024 18:57:20 +0900 Subject: [PATCH] add `@tailrec` --- src/main/scala/scalaprops/ScalapropsMagnoliaCogen.scala | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/scala/scalaprops/ScalapropsMagnoliaCogen.scala b/src/main/scala/scalaprops/ScalapropsMagnoliaCogen.scala index 5da5e3c..42badbe 100644 --- a/src/main/scala/scalaprops/ScalapropsMagnoliaCogen.scala +++ b/src/main/scala/scalaprops/ScalapropsMagnoliaCogen.scala @@ -1,6 +1,7 @@ package scalaprops import magnolia1.{CaseClass, Magnolia, SealedTrait} +import scala.annotation.tailrec object ScalapropsMagnoliaCogen { type Typeclass[T] = scalaprops.Cogen[T] @@ -19,6 +20,7 @@ object ScalapropsMagnoliaCogen { def cogen[B](t: T, g: CogenState[B]) = { val index = ctx.subtypes.indexWhere(_.cast.isDefinedAt(t)) if (index >= 0) { + @tailrec def loop(i: Int, r: Rand): Rand = { if (i <= 0) r else loop(i - 1, g.gen.f(index, r)._1)