@@ -93,11 +93,6 @@ object Names {
93
93
/** Apply `f` to all simple term names making up this name */
94
94
def mapParts (f : SimpleName => SimpleName ): ThisName
95
95
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
-
101
96
/** A name in the same (term or type) namespace as this name and
102
97
* with same characters as given `name`.
103
98
*/
@@ -265,16 +260,24 @@ object Names {
265
260
}
266
261
267
262
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)
275
265
myMangledString
276
266
}
277
267
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
+ }
278
281
}
279
282
280
283
/** A simple name is essentiall an interned string */
@@ -437,7 +440,6 @@ object Names {
437
440
override def collect [T ](f : PartialFunction [Name , T ]): Option [T ] = toTermName.collect(f)
438
441
override def mapLast (f : SimpleName => SimpleName ) = toTermName.mapLast(f).toTypeName
439
442
override def mapParts (f : SimpleName => SimpleName ) = toTermName.mapParts(f).toTypeName
440
- override def split = toTermName.split
441
443
442
444
override def likeSpaced (name : Name ): TypeName = name.toTypeName
443
445
0 commit comments