@@ -1110,7 +1110,10 @@ object Trees {
1110
1110
1111
1111
abstract class TreeMap (val cpy : TreeCopier = inst.cpy) {
1112
1112
1113
- def transform (tree : Tree )(implicit ctx : Context ): Tree =
1113
+ def transform (tree : Tree )(implicit ctx : Context ): Tree = {
1114
+ def localCtx =
1115
+ if (tree.hasType && tree.symbol.exists) ctx.withOwner(tree.symbol) else ctx
1116
+
1114
1117
if (skipTransform(tree)) tree
1115
1118
else tree match {
1116
1119
case Ident (name) =>
@@ -1180,12 +1183,15 @@ object Trees {
1180
1183
case EmptyValDef =>
1181
1184
tree
1182
1185
case tree @ ValDef (name, tpt, _) =>
1186
+ implicit val ctx = localCtx
1183
1187
val tpt1 = transform(tpt)
1184
1188
val rhs1 = transform(tree.rhs)
1185
1189
cpy.ValDef (tree)(name, tpt1, rhs1)
1186
1190
case tree @ DefDef (name, tparams, vparamss, tpt, _) =>
1191
+ implicit val ctx = localCtx
1187
1192
cpy.DefDef (tree)(name, transformSub(tparams), vparamss mapConserve (transformSub(_)), transform(tpt), transform(tree.rhs))
1188
1193
case tree @ TypeDef (name, rhs) =>
1194
+ implicit val ctx = localCtx
1189
1195
cpy.TypeDef (tree)(name, transform(rhs))
1190
1196
case tree @ Template (constr, parents, self, _) =>
1191
1197
cpy.Template (tree)(transformSub(constr), transform(parents), transformSub(self), transformStats(tree.body))
@@ -1201,6 +1207,7 @@ object Trees {
1201
1207
case _ if ctx.reporter.errorsReported =>
1202
1208
tree
1203
1209
}
1210
+ }
1204
1211
1205
1212
def transformStats (trees : List [Tree ])(implicit ctx : Context ): List [Tree ] =
1206
1213
transform(trees)
0 commit comments