@@ -43,9 +43,9 @@ abstract class BTypes[G <: Global](val __global_dont_use: G) {
43
43
case FLOAT => " F"
44
44
case LONG => " J"
45
45
case DOUBLE => " D"
46
- case c @ ClassBType (_, _) => " L" + c. internalName + " ;"
47
- case ArrayBType (component) => " [" + component
48
- case MethodBType (args, res) => " (" + args.mkString + " )" + res
46
+ case ClassBType (internalName) => " L" + internalName + " ;"
47
+ case ArrayBType (component) => " [" + component
48
+ case MethodBType (args, res) => " (" + args.mkString + " )" + res
49
49
}
50
50
51
51
/**
@@ -160,9 +160,9 @@ abstract class BTypes[G <: Global](val __global_dont_use: G) {
160
160
case FLOAT => asm.Type .FLOAT_TYPE
161
161
case LONG => asm.Type .LONG_TYPE
162
162
case DOUBLE => asm.Type .DOUBLE_TYPE
163
- case c @ ClassBType (_, _) => asm.Type .getObjectType(c. internalName) // (*)
164
- case a @ ArrayBType (_) => asm.Type .getObjectType(a.descriptor)
165
- case m @ MethodBType (_, _) => asm.Type .getMethodType(m.descriptor)
163
+ case ClassBType (internalName) => asm.Type .getObjectType(internalName) // see (*) above
164
+ case a : ArrayBType => asm.Type .getObjectType(a.descriptor)
165
+ case m : MethodBType => asm.Type .getMethodType(m.descriptor)
166
166
}
167
167
168
168
def asRefBType : RefBType = this .asInstanceOf [RefBType ]
@@ -227,8 +227,8 @@ abstract class BTypes[G <: Global](val __global_dont_use: G) {
227
227
* This can be verified for example using javap or ASMifier.
228
228
*/
229
229
def classOrArrayType : String = this match {
230
- case c : ClassBType => c. internalName
231
- case a : ArrayBType => a.descriptor
230
+ case ClassBType (internalName) => internalName
231
+ case a : ArrayBType => a.descriptor
232
232
}
233
233
}
234
234
@@ -458,21 +458,23 @@ abstract class BTypes[G <: Global](val __global_dont_use: G) {
458
458
*/
459
459
class ClassBType private (val offset : Int , val length : Int ) extends RefBType {
460
460
/**
461
- * Construct a ClassBType for a given (intenred) class name.
461
+ * Construct a ClassBType from the (intenred) internal name of a class .
462
462
*
463
- * @param n The class name as a slice of the `chrs` array, without the surrounding 'L' and ';'.
464
- * Note that `classSymbol.javaBinaryName` returns exactly such a name.
463
+ * @param internalName The internal name as a slice of the `chrs` array. The internal name does
464
+ * not have the surrounding 'L' and ';'. Note that
465
+ * `classSymbol.javaBinaryName` returns exactly such a name.
465
466
*/
466
- def this (n : BTypeName ) = this (n .start, n .length)
467
+ def this (internalName : BTypeName ) = this (internalName .start, internalName .length)
467
468
468
469
/**
469
- * Construct a ClassBType for a given java class name .
470
+ * Construct a ClassBType from the internal name of a class .
470
471
*
471
- * @param s A class name of the form "java/lang/String", without the surrounding 'L' and ';'.
472
+ * @param internalName The internal name of a class has the form "java/lang/String", without the
473
+ * surrounding 'L' and ';'.
472
474
*/
473
- def this (s : String ) = this ({
474
- assert(! (s .head == 'L' && s .last == ';' ), s " Descriptor instead of internal name: $s " )
475
- createNewName(s )
475
+ def this (internalName : String ) = this ({
476
+ assert(! (internalName .head == 'L' && internalName .last == ';' ), s " Descriptor instead of internal name: $internalName " )
477
+ createNewName(internalName )
476
478
})
477
479
478
480
/**
@@ -490,7 +492,7 @@ abstract class BTypes[G <: Global](val __global_dont_use: G) {
490
492
* Custom equals / hashCode are needed because this is not a case class.
491
493
*/
492
494
override def equals (o : Any ): Boolean = (this eq o.asInstanceOf [Object ]) || (o match {
493
- case ClassBType (` offset`, ` length`) => true
495
+ case c : ClassBType => c. offset == this .offset && c. length == this .length
494
496
case _ => false
495
497
})
496
498
@@ -504,12 +506,15 @@ abstract class BTypes[G <: Global](val __global_dont_use: G) {
504
506
}
505
507
506
508
object ClassBType {
507
- def apply (n : BTypeName ): ClassBType = new ClassBType (n )
508
- def apply (s : String ): ClassBType = new ClassBType (s )
509
+ def apply (internalName : BTypeName ): ClassBType = new ClassBType (internalName )
510
+ def apply (internalName : String ): ClassBType = new ClassBType (internalName )
509
511
510
- def unapply (c : ClassBType ): Option [(Int , Int )] =
512
+ /**
513
+ * Pattern matching on a ClassBType extracts the `internalName` of the class.
514
+ */
515
+ def unapply (c : ClassBType ): Option [String ] =
511
516
if (c == null ) None
512
- else Some ((c.offset, c.length) )
517
+ else Some (c.internalName )
513
518
}
514
519
515
520
case class ArrayBType (componentType : BType ) extends RefBType {
0 commit comments