summaryrefslogtreecommitdiff
path: root/test/files/jvm/t9105.scala
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@gmail.com>2015-01-21 19:57:45 +0100
committerLukas Rytz <lukas.rytz@gmail.com>2015-02-07 07:45:47 +0100
commit0bcc871e3f4c4331fb53ec0e7087669589a607d6 (patch)
tree86af55ac347552c35a8d5b9bf1a6085e9177b3fb /test/files/jvm/t9105.scala
parentd7b11520222c9e995d27de46fecc19c5a1fa5b74 (diff)
downloadscala-0bcc871e3f4c4331fb53ec0e7087669589a607d6.tar.gz
scala-0bcc871e3f4c4331fb53ec0e7087669589a607d6.tar.bz2
scala-0bcc871e3f4c4331fb53ec0e7087669589a607d6.zip
SI-9105 Fix EnclosingMethod for classes defined in lambdas
This change fixes both GenASM and GenBCode, except for the change to renaming in LamdaLift mentioned below. The reason for an inconsistent EnclosingMethod attribute was the symbol owner chain. Initially, closure class symbols don't exist, they are only created in UnCurry (delambdafy:inline). So walking the originalOwner of a definition does not yield closure classes. The commit also fixes uses of isAnonymousClass, isAnonymousFunction and isDelambdafyFunction in two ways: 1. by phase-travelling to an early phase. after flatten, the name includes the name of outer classes, so the properties may become accidentally true (they check for a substring in the name) 2. by ensuring that the (destructive) renames during LambdaLift don't make the above properties accidentally true. This was in fact the cause for SI-8900.
Diffstat (limited to 'test/files/jvm/t9105.scala')
-rw-r--r--test/files/jvm/t9105.scala22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/files/jvm/t9105.scala b/test/files/jvm/t9105.scala
new file mode 100644
index 0000000000..636ee8a768
--- /dev/null
+++ b/test/files/jvm/t9105.scala
@@ -0,0 +1,22 @@
+class C {
+ val fun = () => {
+ class A
+ def m: Object = { class B; new B }
+ val f: Object = { class C; new C }
+ val g = () => { class D; new D }
+ List[Object](new A, m, f, g())
+ }
+ def met = () => {
+ class E
+ def m: Object = { class F; new F }
+ val f: Object = { class G; new G }
+ val g = () => { class H; new H }
+ List[Object](new E, m, f, g())
+ }
+}
+
+object Test extends App {
+ val x = new C().fun.apply() ::: new C().met.apply()
+ val results = x.map(_.getClass).map(cls => (cls, cls.getEnclosingClass, cls.getEnclosingMethod))
+ println(results.mkString("\n"))
+}