@@ -12,11 +12,11 @@ abstract class TreeAccumulator[X, T <: Tasty with Singleton](val tasty: T) {
1212 def foldPattern (x : X , tree : Pattern )(implicit ctx : Context ): X
1313 def foldParent (x : X , tree : Parent )(implicit ctx : Context ): X
1414
15- def foldTree (x : X , trees : Traversable [Tree ])(implicit ctx : Context ): X = (x /: trees)(foldTree)
16- def foldTypeTree (x : X , trees : Traversable [MaybeTypeTree ])(implicit ctx : Context ): X = (x /: trees)(foldTypeTree)
17- def foldCaseDef (x : X , trees : Traversable [CaseDef ])(implicit ctx : Context ): X = (x /: trees)(foldCaseDef)
18- def foldPattern (x : X , trees : Traversable [Pattern ])(implicit ctx : Context ): X = (x /: trees)(foldPattern)
19- def foldParent (x : X , trees : Traversable [Parent ])(implicit ctx : Context ): X = (x /: trees)(foldParent)
15+ def foldTrees (x : X , trees : Iterable [Tree ])(implicit ctx : Context ): X = (x /: trees)(foldTree)
16+ def foldTypeTrees (x : X , trees : Iterable [MaybeTypeTree ])(implicit ctx : Context ): X = (x /: trees)(foldTypeTree)
17+ def foldCaseDefs (x : X , trees : Iterable [CaseDef ])(implicit ctx : Context ): X = (x /: trees)(foldCaseDef)
18+ def foldPatterns (x : X , trees : Iterable [Pattern ])(implicit ctx : Context ): X = (x /: trees)(foldPattern)
19+ def foldParents (x : X , trees : Iterable [Parent ])(implicit ctx : Context ): X = (x /: trees)(foldParent)
2020
2121 def foldOverTree (x : X , tree : Tree )(implicit ctx : Context ): X = {
2222 def localCtx (definition : Definition ): Context = definition.localContext
@@ -30,9 +30,9 @@ abstract class TreeAccumulator[X, T <: Tasty with Singleton](val tasty: T) {
3030 case Super (qual, _) =>
3131 foldTree(x, qual)
3232 case Apply (fun, args) =>
33- foldTree (foldTree(x, fun), args)
33+ foldTrees (foldTree(x, fun), args)
3434 case TypeApply (fun, args) =>
35- foldTypeTree (foldTree(x, fun), args)
35+ foldTypeTrees (foldTree(x, fun), args)
3636 case Literal (const) =>
3737 x
3838 case New (tpt) =>
@@ -44,39 +44,39 @@ abstract class TreeAccumulator[X, T <: Tasty with Singleton](val tasty: T) {
4444 case Assign (lhs, rhs) =>
4545 foldTree(foldTree(x, lhs), rhs)
4646 case Block (stats, expr) =>
47- foldTree(foldTree (x, stats), expr)
47+ foldTree(foldTrees (x, stats), expr)
4848 case If (cond, thenp, elsep) =>
4949 foldTree(foldTree(foldTree(x, cond), thenp), elsep)
5050 case Lambda (meth, tpt) =>
5151 val a = foldTree(x, meth)
5252 tpt.fold(a)(b => foldTypeTree(a, b))
5353 case Match (selector, cases) =>
54- foldCaseDef (foldTree(x, selector), cases)
54+ foldCaseDefs (foldTree(x, selector), cases)
5555 case Return (expr) =>
5656 foldTree(x, expr)
5757 case Try (block, handler, finalizer) =>
58- foldTree(foldCaseDef (foldTree(x, block), handler), finalizer)
58+ foldTrees(foldCaseDefs (foldTree(x, block), handler), finalizer)
5959 case Repeated (elems) =>
60- foldTree (x, elems)
60+ foldTrees (x, elems)
6161 case Inlined (call, bindings, expansion) =>
62- foldTree(foldTree (x, bindings), expansion)
62+ foldTree(foldTrees (x, bindings), expansion)
6363
6464 case vdef @ ValDef (_, tpt, rhs) =>
6565 implicit val ctx = localCtx(vdef)
66- foldTree (foldTypeTree(x, tpt), rhs)
66+ foldTrees (foldTypeTree(x, tpt), rhs)
6767 case ddef @ DefDef (_, tparams, vparamss, tpt, rhs) =>
6868 implicit val ctx = localCtx(ddef)
69- foldTree (foldTypeTree((foldTree (x, tparams) /: vparamss)(foldTree ), tpt), rhs)
69+ foldTrees (foldTypeTree((foldTrees (x, tparams) /: vparamss)(foldTrees ), tpt), rhs)
7070 case tdef @ TypeDef (_, rhs) =>
7171 implicit val ctx = localCtx(tdef)
7272 foldTypeTree(x, rhs)
7373 case cdef @ ClassDef (_, constr, parents, self, body) =>
7474 implicit val ctx = localCtx(cdef)
75- foldTree(foldTree(foldParent (foldTree(x, constr), parents), self), body)
75+ foldTrees(foldTrees(foldParents (foldTree(x, constr), parents), self), body)
7676 case Import (expr, selectors) =>
7777 foldTree(x, expr)
7878 case clause @ PackageClause (pid, stats) =>
79- foldTree (foldTree(x, pid), stats)(localCtx(clause.definition))
79+ foldTrees (foldTree(x, pid), stats)(localCtx(clause.definition))
8080 }
8181 }
8282
@@ -87,22 +87,22 @@ abstract class TreeAccumulator[X, T <: Tasty with Singleton](val tasty: T) {
8787 case Singleton (ref) => foldTree(x, ref)
8888 case And (left, right) => foldTypeTree(foldTypeTree(x, left), right)
8989 case Or (left, right) => foldTypeTree(foldTypeTree(x, left), right)
90- case Refined (tpt, refinements) => foldTree (foldTypeTree(x, tpt), refinements)
91- case Applied (tpt, args) => foldTypeTree (foldTypeTree(x, tpt), args)
90+ case Refined (tpt, refinements) => foldTrees (foldTypeTree(x, tpt), refinements)
91+ case Applied (tpt, args) => foldTypeTrees (foldTypeTree(x, tpt), args)
9292 case ByName (result) => foldTypeTree(x, result)
9393 case Annotated (arg, annot) => foldTree(foldTypeTree(x, arg), annot)
9494 case TypeBoundsTree (lo, hi) => foldTypeTree(foldTypeTree(x, lo), hi)
9595 }
9696
9797 def foldOverCaseDef (x : X , tree : CaseDef )(implicit ctx : Context ): X = tree match {
98- case CaseDef (pat, guard, body) => foldTree(foldTree (foldPattern(x, pat), guard), body)
98+ case CaseDef (pat, guard, body) => foldTree(foldTrees (foldPattern(x, pat), guard), body)
9999 }
100100
101101 def foldOverPattern (x : X , tree : Pattern )(implicit ctx : Context ): X = tree match {
102102 case Value (v) => foldTree(x, v)
103103 case Bind (_, body) => foldPattern(x, body)
104- case Unapply (fun, implicits, patterns) => foldPattern(foldTree (foldTree(x, fun), implicits), patterns)
105- case Alternative (patterns) => foldPattern (x, patterns)
104+ case Unapply (fun, implicits, patterns) => foldPatterns(foldTrees (foldTree(x, fun), implicits), patterns)
105+ case Alternative (patterns) => foldPatterns (x, patterns)
106106 case TypeTest (tpt) => foldTypeTree(x, tpt)
107107 }
108108
0 commit comments