Skip to content
Snippets Groups Projects
Commit 7d4bcf69 authored by Regis Blanc's avatar Regis Blanc
Browse files

generic prefold with context

parent c7aea6cf
No related branches found
No related tags found
No related merge requests found
...@@ -276,6 +276,19 @@ trait SubTreeOps[SubTree <: Tree] { ...@@ -276,6 +276,19 @@ trait SubTreeOps[SubTree <: Tree] {
rec(e, c) rec(e, c)
} }
def preFoldWithContext[C](f: (SubTree, C) => C, combiner: (SubTree, C, Seq[C]) => C)
(e: SubTree, c: C): C = {
def rec(eIn: SubTree, cIn: C): C = {
val ctx = f(eIn, cIn)
val Deconstructor(es, _) = eIn
val cs = es.map{ rec(_, ctx) }
combiner(eIn, ctx, cs)
}
rec(e, c)
}
/* /*
* ============= * =============
* Auxiliary API * Auxiliary API
...@@ -322,4 +335,4 @@ trait SubTreeOps[SubTree <: Tree] { ...@@ -322,4 +335,4 @@ trait SubTreeOps[SubTree <: Tree] {
res res
} }
} }
\ No newline at end of file
...@@ -98,7 +98,7 @@ object Types { ...@@ -98,7 +98,7 @@ object Types {
assert(classDef.tparams.size == tps.size) assert(classDef.tparams.size == tps.size)
def fields = { lazy val fields = {
val tmap = (classDef.tparams zip tps).toMap val tmap = (classDef.tparams zip tps).toMap
if (tmap.isEmpty) { if (tmap.isEmpty) {
classDef.fields classDef.fields
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment