@@ -38,6 +38,7 @@ abstract class LazyVals extends Transform with TypingTransformers with ast.TreeD
38
38
39
39
case ClassDef (_, _, _, _) | DefDef (_, _, _, _, _, _) | ModuleDef (_, _, _) =>
40
40
41
+ // Avoid adding bitmaps when they are fully overshadowed by those that are added inside loops
41
42
case LabelDef (name, _, _) if nme.isLoopHeaderLabel(name) =>
42
43
43
44
case _ =>
@@ -108,22 +109,16 @@ abstract class LazyVals extends Transform with TypingTransformers with ast.TreeD
108
109
}
109
110
110
111
case Template (_, _, body) => atOwner(currentOwner) {
111
- val body1 = super .transformTrees(body)
112
+ // TODO: shady business... can this logic be encapsulated in LocalLazyValFinder?
112
113
var added = false
113
- val stats =
114
- for (stat <- body1) yield stat match {
115
- case Block (_, _) | Apply (_, _) | If (_, _, _) | Try (_, _, _) if ! added =>
116
- // Avoid adding bitmaps when they are fully overshadowed by those
117
- // that are added inside loops
118
- if (LocalLazyValFinder .find(stat)) {
119
- added = true
120
- typed(addBitmapDefs(sym, stat))
121
- } else stat
122
- case ValDef (_, _, _, _) =>
123
- typed(deriveValDef(stat)(addBitmapDefs(stat.symbol, _)))
124
- case _ =>
125
- stat
114
+ val stats = super .transformTrees(body) mapConserve {
115
+ case stat : ValDef => typed(deriveValDef(stat)(addBitmapDefs(stat.symbol, _)))
116
+ case stat : TermTree if ! added && (LocalLazyValFinder find stat) =>
117
+ added = true
118
+ typed(addBitmapDefs(sym, stat))
119
+ case stat => stat
126
120
}
121
+
127
122
val innerClassBitmaps = if (! added && currentOwner.isClass && bitmaps.contains(currentOwner)) {
128
123
// add bitmap to inner class if necessary
129
124
val toAdd0 = bitmaps(currentOwner).map(s => typed(ValDef (s, ZERO )))
0 commit comments