@@ -1110,7 +1110,10 @@ object Trees {
11101110
11111111 abstract class TreeMap (val cpy : TreeCopier = inst.cpy) {
11121112
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+
11141117 if (skipTransform(tree)) tree
11151118 else tree match {
11161119 case Ident (name) =>
@@ -1180,12 +1183,15 @@ object Trees {
11801183 case EmptyValDef =>
11811184 tree
11821185 case tree @ ValDef (name, tpt, _) =>
1186+ implicit val ctx = localCtx
11831187 val tpt1 = transform(tpt)
11841188 val rhs1 = transform(tree.rhs)
11851189 cpy.ValDef (tree)(name, tpt1, rhs1)
11861190 case tree @ DefDef (name, tparams, vparamss, tpt, _) =>
1191+ implicit val ctx = localCtx
11871192 cpy.DefDef (tree)(name, transformSub(tparams), vparamss mapConserve (transformSub(_)), transform(tpt), transform(tree.rhs))
11881193 case tree @ TypeDef (name, rhs) =>
1194+ implicit val ctx = localCtx
11891195 cpy.TypeDef (tree)(name, transform(rhs))
11901196 case tree @ Template (constr, parents, self, _) =>
11911197 cpy.Template (tree)(transformSub(constr), transform(parents), transformSub(self), transformStats(tree.body))
@@ -1201,6 +1207,7 @@ object Trees {
12011207 case _ if ctx.reporter.errorsReported =>
12021208 tree
12031209 }
1210+ }
12041211
12051212 def transformStats (trees : List [Tree ])(implicit ctx : Context ): List [Tree ] =
12061213 transform(trees)
0 commit comments