summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2014-03-17 17:52:13 -0700
committerAdriaan Moors <adriaan.moors@typesafe.com>2014-03-17 17:52:13 -0700
commitdf44b2718dcc489a057d2a60cdaadffed2ce0df5 (patch)
treed8076805cd76cf2e8010519589664ef63dfeb160
parent79f7e05c082a1810f9315e19658e20af15b08235 (diff)
parentd9687d585525476ecd9544b0e367e456af1b0642 (diff)
downloadscala-2.11.0-RC2.tar.gz
scala-2.11.0-RC2.tar.bz2
scala-2.11.0-RC2.zip
Merge pull request #3638 from xeno-by/topic/freshname-hotfixv2.11.0-RC2
SI-8425 don't create double-dollar names in c.freshName
-rw-r--r--src/compiler/scala/reflect/macros/contexts/Names.scala3
-rw-r--r--test/files/run/t8425.check1
-rw-r--r--test/files/run/t8425/Macros_1.scala12
-rw-r--r--test/files/run/t8425/Test_2.scala3
4 files changed, 18 insertions, 1 deletions
diff --git a/src/compiler/scala/reflect/macros/contexts/Names.scala b/src/compiler/scala/reflect/macros/contexts/Names.scala
index 299af40b94..5a5bb428b5 100644
--- a/src/compiler/scala/reflect/macros/contexts/Names.scala
+++ b/src/compiler/scala/reflect/macros/contexts/Names.scala
@@ -33,8 +33,9 @@ trait Names {
//
// TODO: hopefully SI-7823 will provide an ultimate answer to this problem.
// In the meanwhile I will also keep open the original issue: SI-6879 "c.freshName is broken".
+ val prefix = if (name.endsWith("$")) name else name + "$" // SI-8425
val sortOfUniqueSuffix = freshNameCreator.newName(nme.FRESH_SUFFIX)
- name + "$" + sortOfUniqueSuffix
+ prefix + sortOfUniqueSuffix
}
def freshName[NameType <: Name](name: NameType): NameType =
diff --git a/test/files/run/t8425.check b/test/files/run/t8425.check
new file mode 100644
index 0000000000..8379fa0a74
--- /dev/null
+++ b/test/files/run/t8425.check
@@ -0,0 +1 @@
+List(fresh$macro$1, $macro$2)
diff --git a/test/files/run/t8425/Macros_1.scala b/test/files/run/t8425/Macros_1.scala
new file mode 100644
index 0000000000..71a96518e8
--- /dev/null
+++ b/test/files/run/t8425/Macros_1.scala
@@ -0,0 +1,12 @@
+import scala.language.experimental.macros
+import scala.reflect.macros.blackbox.Context
+
+object Macros {
+ def foo: Unit = macro impl
+ def impl(c: Context) = {
+ import c.universe._
+ val test1 = c.freshName()
+ val test2 = c.freshName("$")
+ q"println(List($test1, $test2))"
+ }
+} \ No newline at end of file
diff --git a/test/files/run/t8425/Test_2.scala b/test/files/run/t8425/Test_2.scala
new file mode 100644
index 0000000000..acfddae942
--- /dev/null
+++ b/test/files/run/t8425/Test_2.scala
@@ -0,0 +1,3 @@
+object Test extends App {
+ Macros.foo
+} \ No newline at end of file