summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKato Kazuyoshi <kato.kazuyoshi@gmail.com>2013-04-02 23:19:48 +0900
committerKato Kazuyoshi <kato.kazuyoshi@gmail.com>2013-04-03 00:54:47 +0900
commit8e8370362f7c779139a07acaf5de32137dd2ae1b (patch)
treec183579c0b444ab13267ac5281d059e39cdb0203 /src
parent761df4bb82cabdad7f9922f9cf04043f821827ae (diff)
downloadscala-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.
Diffstat (limited to 'src')
-rw-r--r--src/reflect/scala/reflect/internal/StdNames.scala17
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 = (