@@ -182,13 +182,13 @@ object NameKinds {
182
182
case DerivedName (underlying, info : this .NumberedInfo ) => Some ((underlying, info.num))
183
183
case _ => None
184
184
}
185
- protected def skipSeparatorAndNum (name : SimpleName , separator : String ): Int = {
185
+ protected def skipSeparatorAndNum (name : SimpleName , separator : String ): Int =
186
186
var i = name.length
187
- while (i > 0 && name(i - 1 ).isDigit) i -= 1
188
- if (i > separator.length && i < name.length &&
189
- name.slice(i - separator.length, i).toString == separator) i
187
+ while i > 0 && name(i - 1 ).isDigit do i -= 1
188
+ if i >= separator.length && i < name.length
189
+ && name.slice(i - separator.length, i).toString == separator
190
+ then i
190
191
else - 1
191
- }
192
192
193
193
numberedNameKinds(tag) = this : @ unchecked
194
194
}
@@ -240,6 +240,16 @@ object NameKinds {
240
240
}
241
241
}
242
242
243
+ /** Unique names that can be unmangled */
244
+ class UniqueNameKindWithUnmangle (separator : String ) extends UniqueNameKind (separator):
245
+ override def unmangle (name : SimpleName ): TermName =
246
+ val i = skipSeparatorAndNum(name, separator)
247
+ if i > 0 then
248
+ val index = name.drop(i).toString.toInt
249
+ val original = name.take(i - separator.length).asTermName
250
+ apply(original, index)
251
+ else name
252
+
243
253
/** Names of the form `prefix . name` */
244
254
val QualifiedName : QualifiedNameKind = new QualifiedNameKind (QUALIFIED , " ." )
245
255
@@ -288,7 +298,7 @@ object NameKinds {
288
298
*
289
299
* The "evidence$" prefix is a convention copied from Scala 2.
290
300
*/
291
- val ContextBoundParamName : UniqueNameKind = new UniqueNameKind (" evidence$" )
301
+ val ContextBoundParamName : UniqueNameKind = new UniqueNameKindWithUnmangle (" evidence$" )
292
302
293
303
/** The name of an inferred contextual function parameter:
294
304
*
@@ -323,20 +333,7 @@ object NameKinds {
323
333
val InlineBinderName : UniqueNameKind = new UniqueNameKind (" $proxy" )
324
334
val MacroNames : UniqueNameKind = new UniqueNameKind (" $macro$" )
325
335
326
- /** A kind of unique extension methods; Unlike other unique names, these can be
327
- * unmangled.
328
- */
329
- val UniqueExtMethName : UniqueNameKind = new UniqueNameKind (" $extension" ) {
330
- override def unmangle (name : SimpleName ): TermName = {
331
- val i = skipSeparatorAndNum(name, separator)
332
- if (i > 0 ) {
333
- val index = name.drop(i).toString.toInt
334
- val original = name.take(i - separator.length).asTermName
335
- apply(original, index)
336
- }
337
- else name
338
- }
339
- }
336
+ val UniqueExtMethName : UniqueNameKind = new UniqueNameKindWithUnmangle (" $extension" )
340
337
341
338
/** Kinds of unique names generated by the pattern matcher */
342
339
val PatMatStdBinderName : UniqueNameKind = new UniqueNameKind (" x" )
0 commit comments