diff options
author | Kato Kazuyoshi <kato.kazuyoshi@gmail.com> | 2013-04-02 23:19:48 +0900 |
---|---|---|
committer | Kato Kazuyoshi <kato.kazuyoshi@gmail.com> | 2013-04-03 00:54:47 +0900 |
commit | 8e8370362f7c779139a07acaf5de32137dd2ae1b (patch) | |
tree | c183579c0b444ab13267ac5281d059e39cdb0203 | |
parent | 761df4bb82cabdad7f9922f9cf04043f821827ae (diff) | |
download | scala-8e8370362f7c779139a07acaf5de32137dd2ae1b.tar.gz scala-8e8370362f7c779139a07acaf5de32137dd2ae1b.tar.bz2 scala-8e8370362f7c779139a07acaf5de32137dd2ae1b.zip |
Backport #2289's TermNames.unexpandedName as TermNames.originalName
Because this implementation is more clear than 2.10.x's and it will
simplify a further commit to fix SI-6715.
-rw-r--r-- | src/reflect/scala/reflect/internal/StdNames.scala | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/reflect/scala/reflect/internal/StdNames.scala b/src/reflect/scala/reflect/internal/StdNames.scala index bcda2bc1ae..d97eaabf72 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 => 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 = ( |