Skip to content

Commit 263c377

Browse files
slothspotallanrenucci
authored andcommitted
Add UntypedTreeTraverser
1 parent c17dda0 commit 263c377

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,12 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
596596
}
597597
}
598598

599+
abstract class UntypedTreeTraverser extends UntypedTreeAccumulator[Unit] {
600+
def traverse(tree: Tree)(implicit ctx: Context): Unit
601+
def apply(x: Unit, tree: Tree)(implicit ctx: Context) = traverse(tree)
602+
protected def traverseChildren(tree: Tree)(implicit ctx: Context) = foldOver((), tree)
603+
}
604+
599605
/** Fold `f` over all tree nodes, in depth-first, prefix order */
600606
class UntypedDeepFolder[X](f: (X, Tree) => X) extends UntypedTreeAccumulator[X] {
601607
def apply(x: X, tree: Tree)(implicit ctx: Context): X = foldOver(f(x, tree), tree)

0 commit comments

Comments
 (0)