@@ -132,6 +132,13 @@ object NameKinds {
132132 case  DerivedTermName (underlying, info : this .NumberedInfo ) =>  Some ((underlying, info.num))
133133 case  _ =>  None 
134134 }
135+  protected  def  skipSeparatorAndNum (name : SimpleTermName , separator : String ):  Int  =  {
136+  var  i  =  name.length
137+  while  (i >  0  &&  name(i -  1 ).isDigit) i -=  1 
138+  if  (i >  separator.length &&  i <  name.length && 
139+  name.slice(i -  separator.length, i).toString ==  separator) i
140+  else  - 1 
141+  }
135142 }
136143
137144 case  class  UniqueNameKind (val  separator :  String )
@@ -205,6 +212,18 @@ object NameKinds {
205212 val  SkolemName  =  new  UniqueNameKind (" ?" 
206213 val  LiftedTreeName  =  new  UniqueNameKind (" liftedTree" 
207214
215+  val  UniqueExtMethName  =  new  UniqueNameKind (" $extension" 
216+  override  def  unmangle (name : SimpleTermName ):  TermName  =  {
217+  val  i  =  skipSeparatorAndNum(name, separator)
218+  if  (i >  0 ) {
219+  val  index  =  name.drop(i).toString.toInt
220+  var  original  =  name.take(i -  separator.length).asTermName
221+  apply(original, index)
222+  }
223+  else  name
224+  }
225+  }
226+ 
208227 val  PatMatStdBinderName  =  new  UniqueNameKind (" x" 
209228 val  PatMatPiName  =  new  UniqueNameKind (" pi" //  FIXME: explain what this is
210229 val  PatMatPName  =  new  UniqueNameKind (" p" //  FIXME: explain what this is
@@ -218,15 +237,12 @@ object NameKinds {
218237 val  prefix  =  if  (underlying.isConstructorName) nme.DEFAULT_GETTER_INIT  else  underlying
219238 prefix.toString +  str.DEFAULT_GETTER  +  (info.num +  1 )
220239 }
221- 
222-  private  val  dgLen  =  str.DEFAULT_GETTER .length
223- 
240+  //  TODO: Reduce code duplication with UniqueExtMethName
224241 override  def  unmangle (name : SimpleTermName ):  TermName  =  {
225-  var  i  =  name.length
226-  while  (i >  0  &&  name(i -  1 ).isDigit) i -=  1 
227-  if  (i >  dgLen &&  i <  name.length &&  name.slice(i -  dgLen, i) ==  nme.DEFAULT_GETTER ) {
242+  val  i  =  skipSeparatorAndNum(name, str.DEFAULT_GETTER )
243+  if  (i >  0 ) {
228244 val  index  =  name.drop(i).toString.toInt -  1 
229-  var  original  =  name.take(i -  dgLen ).asTermName
245+  var  original  =  name.take(i -  str. DEFAULT_GETTER .length ).asTermName
230246 if  (original ==  nme.DEFAULT_GETTER_INIT ) original =  Names .CONSTRUCTOR 
231247 apply(original, index)
232248 }
@@ -260,6 +276,7 @@ object NameKinds {
260276 val  AvoidClashName  =  new  SuffixNameKind (AVOIDCLASH , " $_avoid_name_clash_$" 
261277 val  DirectName  =  new  SuffixNameKind (DIRECT , " $direct" 
262278 val  FieldName  =  new  SuffixNameKind (FIELD , " $$local" 
279+  val  ExtMethName  =  new  SuffixNameKind (EXTMETH , " $extension" 
263280 val  ModuleVarName  =  new  SuffixNameKind (OBJECTVAR , " $module" 
264281 val  ModuleClassName  =  new  SuffixNameKind (OBJECTCLASS , " $" =  " ModuleClass" 
265282
@@ -283,7 +300,7 @@ object NameKinds {
283300 }
284301
285302 val  Scala2MethodNameKinds :  List [NameKind ] = 
286-  List (DefaultGetterName , ProtectedAccessorName , ProtectedSetterName )
303+  List (DefaultGetterName , ExtMethName ,  UniqueExtMethName ,  ProtectedAccessorName , ProtectedSetterName )
287304
288305 def  simpleNameKindOfTag  :  collection.Map [Int , ClassifiedNameKind ] =  simpleNameKinds
289306 def  qualifiedNameKindOfTag  :  collection.Map [Int , QualifiedNameKind ] =  qualifiedNameKinds
0 commit comments