summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2011-05-16 14:37:10 +0000
committerMartin Odersky <odersky@gmail.com>2011-05-16 14:37:10 +0000
commit7127d8293775905acd0d04e21d9e045b5c029261 (patch)
tree312cc970ff0f41ae1c2f28c1f851b846c750237b
parent782c73313ecaa726d7341bebdfc316389a69caa5 (diff)
downloadscala-7127d8293775905acd0d04e21d9e045b5c029261.tar.gz
scala-7127d8293775905acd0d04e21d9e045b5c029261.tar.bz2
scala-7127d8293775905acd0d04e21d9e045b5c029261.zip
Closes 4560. Review by dragos.
-rw-r--r--src/compiler/scala/tools/nsc/transform/CleanUp.scala12
-rw-r--r--test/files/run/t4560.check1
-rw-r--r--test/files/run/t4560.scala16
3 files changed, 23 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
index 41faf00a04..aa829d61ab 100644
--- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala
+++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
@@ -34,14 +34,14 @@ abstract class CleanUp extends Transform with ast.TreeDSL {
* the enclosing implementation class instead.
*/
def safeREF(sym: Symbol) = {
- def fix(tree: Tree): Tree = tree match {
- case Select(qual, name) => treeCopy.Select(tree, fix(qual), name)
- case This(_) if tree.symbol.isInterface && tree.symbol.name + "$class" == currentClass.name.toString =>
- tree.setSymbol(currentClass).setType(currentClass.tpe)
- case _ => tree
+ def fix(tree: Tree): Unit = tree match {
+ case Select(qual @ This(_), name) if qual.symbol != currentClass =>
+ qual.setSymbol(currentClass).setType(currentClass.tpe)
+ case _ =>
}
val tree = REF(sym)
- if (currentClass.isImplClass) fix(tree) else tree
+ if (currentClass.isImplClass && sym.owner == currentClass) fix(tree)
+ tree
}
//private val classConstantMeth = new HashMap[String, Symbol]
diff --git a/test/files/run/t4560.check b/test/files/run/t4560.check
index 7ed6ff82de..fd3c81a4d7 100644
--- a/test/files/run/t4560.check
+++ b/test/files/run/t4560.check
@@ -1 +1,2 @@
5
+5
diff --git a/test/files/run/t4560.scala b/test/files/run/t4560.scala
index f1eb5d4169..f809e67898 100644
--- a/test/files/run/t4560.scala
+++ b/test/files/run/t4560.scala
@@ -16,8 +16,24 @@ trait B {
}
}
+class A2
+
+trait B2 {
+ self: A2 =>
+
+ def test {
+ import Pimper.pimp
+
+ println(5.test)
+ }
+}
+
object Test extends A with B {
def main(args: Array[String]) {
test
+ Test2.test
}
}
+
+object Test2 extends A2 with B2
+