Skip to content

Commit e5ce083

Browse files
committed
Add Types#TypeTraverser for convenience
This works similarly to `Trees#TreeTraverser`.
1 parent 5cf997c commit e5ce083

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/dotty/tools/dotc/core/Types.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3408,6 +3408,12 @@ object Types {
34083408
}
34093409
}
34103410

3411+
abstract class TypeTraverser(implicit ctx: Context) extends TypeAccumulator[Unit] {
3412+
def traverse(tp: Type): Unit
3413+
def apply(x: Unit, tp: Type): Unit = traverse(tp)
3414+
protected def traverseChildren(tp: Type) = foldOver((), tp)
3415+
}
3416+
34113417
class ExistsAccumulator(p: Type => Boolean)(implicit ctx: Context) extends TypeAccumulator[Boolean] {
34123418
override def stopAtStatic = false
34133419
def apply(x: Boolean, tp: Type) = x || p(tp) || foldOver(x, tp)

0 commit comments

Comments
 (0)