summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2014-05-11 13:50:09 +0200
committerJason Zaugg <jzaugg@gmail.com>2014-05-11 13:52:42 +0200
commitf13c07fe29d27bdc75423be6d3bf5458175bec90 (patch)
treeb46d2a8c68735e0d80bf181c0423e9cc18cb73c7
parent3f28bbed6d1c2d49201da700907aae460f15cd4d (diff)
downloadscala-f13c07fe29d27bdc75423be6d3bf5458175bec90.tar.gz
scala-f13c07fe29d27bdc75423be6d3bf5458175bec90.tar.bz2
scala-f13c07fe29d27bdc75423be6d3bf5458175bec90.zip
SI-8578 Avoid fresh name clashes under -Ydelambdafy:method
It is important to append the fresh 'N' after '$'. Otherwise, we find out the hard way that ("foo$11" + "1") == ("foo$1" + "11").
-rw-r--r--src/compiler/scala/tools/nsc/transform/Delambdafy.scala2
-rw-r--r--test/files/pos/t8578.flags1
-rw-r--r--test/files/pos/t8578.scala18
3 files changed, 20 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/Delambdafy.scala b/src/compiler/scala/tools/nsc/transform/Delambdafy.scala
index 1468680fe0..d66e53edca 100644
--- a/src/compiler/scala/tools/nsc/transform/Delambdafy.scala
+++ b/src/compiler/scala/tools/nsc/transform/Delambdafy.scala
@@ -238,7 +238,7 @@ abstract class Delambdafy extends Transform with TypingTransformers with ast.Tre
// - reinstate the assertion in `Erasure.resolveAnonymousBridgeClash`
val suffix = "$lambda$" + (
if (funOwner.isPrimaryConstructor) ""
- else "$" + funOwner.name
+ else "$" + funOwner.name + "$"
)
val name = unit.freshTypeName(s"${oldClass.name.decode}$suffix")
diff --git a/test/files/pos/t8578.flags b/test/files/pos/t8578.flags
new file mode 100644
index 0000000000..48b438ddf8
--- /dev/null
+++ b/test/files/pos/t8578.flags
@@ -0,0 +1 @@
+-Ydelambdafy:method
diff --git a/test/files/pos/t8578.scala b/test/files/pos/t8578.scala
new file mode 100644
index 0000000000..879b5f5550
--- /dev/null
+++ b/test/files/pos/t8578.scala
@@ -0,0 +1,18 @@
+class DuplicateClassName {
+ () => {
+ {() => ()}
+ {() => ()}
+ {() => ()}
+ {() => ()}
+ {() => ()}
+ {() => ()}
+ {() => ()}
+ {() => ()}
+ {() => ()}
+ {() => () => ()}
+ {() => ()}
+ }
+}
+// Was:
+// Different class symbols have the same bytecode-level internal name:
+// name: DuplicateClassName$lambda$$$anonfun$111 \ No newline at end of file