Skip to content

Commit 2320ed0

Browse files
committed
Add UntypedTreeTraverser
1 parent 4e5cf82 commit 2320ed0

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
@@ -582,6 +582,12 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
582582
}
583583
}
584584

585+
abstract class UntypedTreeTraverser extends UntypedTreeAccumulator[Unit] {
586+
def traverse(tree: Tree)(implicit ctx: Context): Unit
587+
def apply(x: Unit, tree: Tree)(implicit ctx: Context) = traverse(tree)
588+
protected def traverseChildren(tree: Tree)(implicit ctx: Context) = foldOver((), tree)
589+
}
590+
585591
/** Fold `f` over all tree nodes, in depth-first, prefix order */
586592
class UntypedDeepFolder[X](f: (X, Tree) => X) extends UntypedTreeAccumulator[X] {
587593
def apply(x: X, tree: Tree)(implicit ctx: Context): X = foldOver(f(x, tree), tree)

0 commit comments

Comments
 (0)