File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -228,17 +228,23 @@ object Eval extends EvalInstances {
228228
229229 object Call {
230230 /** Collapse the call stack for eager evaluations */
231- private def loop [A ](fa : Eval [A ]): Eval [A ] = fa match {
231+ @ tailrec private def loop [A ](fa : Eval [A ]): Eval [A ] = fa match {
232232 case call : Eval .Call [A ] =>
233233 loop(call.thunk())
234234 case compute : Eval .Compute [A ] =>
235235 new Eval .Compute [A ] {
236236 type Start = compute.Start
237237 val start : () => Eval [Start ] = () => compute.start()
238- val run : Start => Eval [A ] = s => loop (compute.run(s))
238+ val run : Start => Eval [A ] = s => loop1 (compute.run(s))
239239 }
240240 case other => other
241241 }
242+
243+ /**
244+ * Alias for loop that can be called in a non-tail position
245+ * from an otherwise tailrec-optimized loop.
246+ */
247+ private def loop1 [A ](fa : Eval [A ]): Eval [A ] = loop(fa)
242248 }
243249
244250 /**
You can’t perform that action at this time.
0 commit comments