From 8e8370362f7c779139a07acaf5de32137dd2ae1b Mon Sep 17 00:00:00 2001 From: Kato Kazuyoshi Date: Tue, 2 Apr 2013 23:19:48 +0900 Subject: 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. --- src/reflect/scala/reflect/internal/StdNames.scala | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src') 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 = ( -- cgit v1.2.3