Skip to content

Commit c0a4ed0

Browse files
committed
Attempt a fix to a potential problem in RecursionOverflow
1 parent 45476f2 commit c0a4ed0

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

compiler/src/dotty/tools/dotc/core/TypeErrors.scala

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,22 @@ class MissingType(pre: Type, name: Name) extends TypeError {
4040
}
4141
}
4242

43-
class RecursionOverflow(val op: String, details: => String, previous: Throwable, val weight: Int) extends TypeError {
43+
class RecursionOverflow(val op: String, details: => String, val previous: Throwable, val weight: Int) extends TypeError {
4444

4545
def explanation: String = s"$op $details"
4646

4747
private def recursions: List[RecursionOverflow] = {
48-
val nested = previous match {
49-
case previous: RecursionOverflow => previous.recursions
50-
case _ => Nil
48+
import scala.collection.mutable.ListBuffer
49+
val result = ListBuffer.empty[RecursionOverflow]
50+
@annotation.tailrec def loop(throwable: Throwable): List[RecursionOverflow] = throwable match {
51+
case ro: RecursionOverflow =>
52+
if (result.contains(ro)) println("caught the issue")
53+
result += ro
54+
loop(ro.previous)
55+
case _ => result.toList
56+
5157
}
52-
this :: nested
58+
loop(this)
5359
}
5460

5561
def opsString(rs: List[RecursionOverflow])(implicit ctx: Context): String = {

0 commit comments

Comments
 (0)