Skip to content

Commit ee4b125

Browse files
committed
Avoid stackoverflow in bootstrap test
tests/run/t10594.scala
1 parent fbe2304 commit ee4b125

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

compiler/src/dotty/tools/dotc/ast/Trees.scala

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,11 +1379,13 @@ object Trees {
13791379
// Ties the knot of the traversal: call `foldOver(x, tree))` to dive in the `tree` node.
13801380
def apply(x: X, tree: Tree)(using Context): X
13811381

1382-
def apply(x: X, trees: List[Tree])(using Context): X = trees match
1383-
case tree :: rest =>
1384-
apply(apply(x, tree), rest)
1385-
case Nil =>
1386-
x
1382+
def apply(x: X, trees: List[Tree])(using Context): X =
1383+
var acc = x
1384+
var list = trees
1385+
while (!list.isEmpty) do
1386+
acc = apply(acc, list.head)
1387+
list = list.tail
1388+
acc
13871389

13881390
def foldOver(x: X, tree: Tree)(using Context): X =
13891391
if (tree.source != ctx.source && tree.source.exists)

0 commit comments

Comments
 (0)