aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-11-03 10:31:24 +0100
committerMartin Odersky <odersky@gmail.com>2014-11-09 19:08:59 +0100
commitb98ed348f16958c300cd3c98aac665f7a6d76bb2 (patch)
tree836b716b0c2159baceed5cce7563bf7e88697b4b
parentb8b06825fe575d7a6750874299cb356da99f5bc6 (diff)
downloaddotty-b98ed348f16958c300cd3c98aac665f7a6d76bb2.tar.gz
dotty-b98ed348f16958c300cd3c98aac665f7a6d76bb2.tar.bz2
dotty-b98ed348f16958c300cd3c98aac665f7a6d76bb2.zip
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.
-rw-r--r--src/dotty/tools/dotc/ast/tpd.scala3
1 files changed, 2 insertions, 1 deletions
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)