@@ -93,11 +93,6 @@ object Names {
9393 /** Apply `f` to all simple term names making up this name */
9494 def mapParts (f : SimpleName => SimpleName ): ThisName
9595
96- /** If this a qualified name, split it into underlyng, last part, and separator
97- * Otherwise return an empty name, the name itself, and "")
98- */
99- def split : (TermName , TermName , String )
100-
10196 /** A name in the same (term or type) namespace as this name and
10297 * with same characters as given `name`.
10398 */
@@ -265,16 +260,24 @@ object Names {
265260 }
266261
267262 final def mangledString : String = {
268- if (myMangledString == null ) {
269- val (prefix, suffix, separator) = split
270- val mangledSuffix = suffix.mangled.toString
271- myMangledString =
272- if (prefix.isEmpty) mangledSuffix
273- else str.sanitize(prefix.mangledString + separator + mangledSuffix)
274- }
263+ if (myMangledString == null )
264+ myMangledString = qualToString(_.mangledString, _.mangled.toString)
275265 myMangledString
276266 }
277267
268+ /** If this a qualified name, split it into underlyng, last part, and separator
269+ * Otherwise return an empty name, the name itself, and "")
270+ */
271+ def split : (TermName , TermName , String )
272+
273+ /** Convert to string as follows. If this is a qualified name
274+ * `<first> <sep> <last>`, the sanitized version of `f1(<first>) <sep> f2(<last>)`.
275+ * Otherwise `f2` applied to this name.
276+ */
277+ def qualToString (f1 : TermName => String , f2 : TermName => String ) = {
278+ val (first, last, sep) = split
279+ if (first.isEmpty) f2(last) else str.sanitize(f1(first) + sep + f2(last))
280+ }
278281 }
279282
280283 /** A simple name is essentiall an interned string */
@@ -437,7 +440,6 @@ object Names {
437440 override def collect [T ](f : PartialFunction [Name , T ]): Option [T ] = toTermName.collect(f)
438441 override def mapLast (f : SimpleName => SimpleName ) = toTermName.mapLast(f).toTypeName
439442 override def mapParts (f : SimpleName => SimpleName ) = toTermName.mapParts(f).toTypeName
440- override def split = toTermName.split
441443
442444 override def likeSpaced (name : Name ): TypeName = name.toTypeName
443445
0 commit comments