diff options
-rw-r--r-- | src/reflect/scala/reflect/internal/StdNames.scala | 17 | ||||
-rw-r--r-- | test/files/run/t6715.scala | 15 | ||||
-rw-r--r-- | test/scaladoc/run/SI-6715.check | 1 | ||||
-rw-r--r-- | test/scaladoc/run/SI-6715.scala | 15 |
4 files changed, 41 insertions, 7 deletions
diff --git a/src/reflect/scala/reflect/internal/StdNames.scala b/src/reflect/scala/reflect/internal/StdNames.scala index bcda2bc1ae..de7af4340d 100644 --- a/src/reflect/scala/reflect/internal/StdNames.scala +++ b/src/reflect/scala/reflect/internal/StdNames.scala @@ -381,13 +381,16 @@ trait StdNames { /** If `name` is an expandedName name, the original name. * Otherwise `name` itself. */ - def originalName(name: Name): Name = { - var i = name.length - while (i >= 2 && !(name.charAt(i - 1) == '$' && name.charAt(i - 2) == '$')) i -= 1 - if (i >= 2) { - while (i >= 3 && name.charAt(i - 3) == '$') i -= 1 - name.subName(i, name.length) - } else name + def originalName(name: Name): Name = name.toString lastIndexOf "$$" match { + case -1 | 0 => name + case idx0 => + // Sketchville - We've found $$ but if it's part of $$$ or $$$$ + // or something we need to keep the bonus dollars, so e.g. foo$$$outer + // has an original name of $outer. + var idx = idx0 + while (idx > 0 && name.charAt(idx - 1) == '$') + idx -= 1 + name drop idx + 2 } def unspecializedName(name: Name): Name = ( diff --git a/test/files/run/t6715.scala b/test/files/run/t6715.scala new file mode 100644 index 0000000000..07ff34218a --- /dev/null +++ b/test/files/run/t6715.scala @@ -0,0 +1,15 @@ +import scala.reflect.runtime.universe._ + +class A { + def $$ = 1 + def $times = 1 +} + +object Test { + def main(args: Array[String]): Unit = { + val memberSet: Set[String] = typeOf[A].members.map{ _.toString }.toSet + assert(memberSet contains "method *") + assert(memberSet contains "method $$") + assert(! (memberSet contains "method")) + } +} diff --git a/test/scaladoc/run/SI-6715.check b/test/scaladoc/run/SI-6715.check new file mode 100644 index 0000000000..619c56180b --- /dev/null +++ b/test/scaladoc/run/SI-6715.check @@ -0,0 +1 @@ +Done. diff --git a/test/scaladoc/run/SI-6715.scala b/test/scaladoc/run/SI-6715.scala new file mode 100644 index 0000000000..92d3376234 --- /dev/null +++ b/test/scaladoc/run/SI-6715.scala @@ -0,0 +1,15 @@ +import scala.tools.nsc.doc.model._ +import scala.tools.partest.ScaladocModelTest + +object Test extends ScaladocModelTest { + def scaladocSettings = "" + + override def code = "object A { def $$ = 123 }" + + def testModel(rootPackage: Package) = { + import access._ + + val method = rootPackage._object("A")._method("$$") + assert(method != null) + } +} |