From b98ed348f16958c300cd3c98aac665f7a6d76bb2 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 3 Nov 2014 10:31:24 +0100 Subject: Fix problem in changeOwner The problem manifests itself when changing the owner of a class field. Being a ValDef, this is classified as a weak owner. But it's parent (the class) should not be owner-changed. --- src/dotty/tools/dotc/ast/tpd.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/dotty/tools/dotc/ast/tpd.scala b/src/dotty/tools/dotc/ast/tpd.scala index 8c300c231..6aa715c8e 100644 --- a/src/dotty/tools/dotc/ast/tpd.scala +++ b/src/dotty/tools/dotc/ast/tpd.scala @@ -527,7 +527,8 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { */ def changeOwner(from: Symbol, to: Symbol)(implicit ctx: Context): ThisTree = { def loop(from: Symbol, froms: List[Symbol], tos: List[Symbol]): ThisTree = { - if (from.isWeakOwner) loop(from.owner, from :: froms, to :: tos) + if (from.isWeakOwner && !from.owner.isClass) + loop(from.owner, from :: froms, to :: tos) else { //println(i"change owner ${from :: froms}%, % ==> $tos of $tree") new TreeTypeMap(oldOwners = from :: froms, newOwners = tos).apply(tree) -- cgit v1.2.3