summaryrefslogtreecommitdiff
path: root/test/files/run
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2014-10-07 15:09:28 +1000
committerJason Zaugg <jzaugg@gmail.com>2014-10-07 15:09:28 +1000
commit1ee6352a79d0b9001f4f1249708e7c6350b241ae (patch)
tree0908d86afb4cac6f37ee0bcaaeabf745cf4e0c06 /test/files/run
parent7b2c3cb8bb0f5f96f3182f551eb82cb1c59d460c (diff)
downloadscala-1ee6352a79d0b9001f4f1249708e7c6350b241ae.tar.gz
scala-1ee6352a79d0b9001f4f1249708e7c6350b241ae.tar.bz2
scala-1ee6352a79d0b9001f4f1249708e7c6350b241ae.zip
SI-8888 Avoid ClassFormatError under -Ydelambdafy:method
The pattern matcher phase (conceivably, among others) can generate code that binds local `Ident`s symbolically, rather than according to the lexical scope. This means that a lambda can capture more than one local of the same name. In the enclosed test case, this ends up creating the following tree after delambdafy [[syntax trees at end of delambdafy]] // delambday-patmat-path-dep.scala matchEnd4({ case <synthetic> val x1: Object = (x2: Object); case5(){ if (x1.$isInstanceOf[C]()) { <synthetic> val x2#19598: C = (x1.$asInstanceOf[C](): C); matchEnd4({ { (new resume$1(x2#19598, x2#19639): runtime.AbstractFunction0) }; scala.runtime.BoxedUnit.UNIT }) } else case6() }; ... }) ... <synthetic> class resume$1 extends AbstractFunction0 { <synthetic> var x2: C = null; <synthetic> var x2: C = null; ... } After this commit, the var members of `resume$1` are given fresh names, rather than directly using the name of the captured var: <synthetic> var x2$3: C = null; <synthetic> var x2$4: C = null;
Diffstat (limited to 'test/files/run')
-rw-r--r--test/files/run/t8888.flags1
-rw-r--r--test/files/run/t8888.scala12
2 files changed, 13 insertions, 0 deletions
diff --git a/test/files/run/t8888.flags b/test/files/run/t8888.flags
new file mode 100644
index 0000000000..48b438ddf8
--- /dev/null
+++ b/test/files/run/t8888.flags
@@ -0,0 +1 @@
+-Ydelambdafy:method
diff --git a/test/files/run/t8888.scala b/test/files/run/t8888.scala
new file mode 100644
index 0000000000..36cc1ddf3e
--- /dev/null
+++ b/test/files/run/t8888.scala
@@ -0,0 +1,12 @@
+class C {
+ final def resume: Unit = (this: Any) match {
+ case x : C => (x: Any) match {
+ case y : C =>
+ () => (x, y) // used to trigger a ClassFormatError under -Ydelambdafy:method
+ }
+ }
+}
+
+object Test extends App {
+ new C().resume
+}