Skip to content

Commit 82bf1bb

Browse files
Fix ShallowFolder
1 parent db974a3 commit 82bf1bb

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,9 @@ object Trees {
11901190
}
11911191

11921192
abstract class TreeAccumulator[X] {
1193+
// Ties the knot of the traversal: call `foldOver(x, tree))` to dive in the `tree` node.
11931194
def apply(x: X, tree: Tree)(implicit ctx: Context): X
1195+
11941196
def apply(x: X, trees: Traversable[Tree])(implicit ctx: Context): X = (x /: trees)(apply)
11951197
def foldOver(x: X, tree: Tree)(implicit ctx: Context): X = {
11961198
def localCtx =
@@ -1301,7 +1303,7 @@ object Trees {
13011303
class ShallowFolder[X](f: (X, Tree) => X) extends TreeAccumulator[X] {
13021304
def apply(x: X, tree: Tree)(implicit ctx: Context): X = {
13031305
val x1 = f(x, tree)
1304-
if (x1.asInstanceOf[AnyRef] ne x1.asInstanceOf[AnyRef]) x1
1306+
if (x1.asInstanceOf[AnyRef] ne x.asInstanceOf[AnyRef]) x1
13051307
else foldOver(x1, tree)
13061308
}
13071309
}

0 commit comments

Comments
 (0)