@@ -467,10 +467,10 @@ class Definitions {
467
467
def ArrayModule (implicit ctx : Context ): ClassSymbol = ArrayModuleType .symbol.moduleClass.asClass
468
468
469
469
470
- lazy val UnitType : TypeRef = valueTypeRef(" scala.Unit" , BoxedUnitType , java.lang.Void .TYPE , UnitEnc , nme.specializedTypeNames.Void )
470
+ lazy val UnitType : TypeRef = valueTypeRef(" scala.Unit" , java.lang.Void .TYPE , UnitEnc , nme.specializedTypeNames.Void )
471
471
def UnitClass (implicit ctx : Context ): ClassSymbol = UnitType .symbol.asClass
472
472
def UnitModuleClass (implicit ctx : Context ): Symbol = UnitType .symbol.asClass.linkedClass
473
- lazy val BooleanType : TypeRef = valueTypeRef(" scala.Boolean" , BoxedBooleanType , java.lang.Boolean .TYPE , BooleanEnc , nme.specializedTypeNames.Boolean )
473
+ lazy val BooleanType : TypeRef = valueTypeRef(" scala.Boolean" , java.lang.Boolean .TYPE , BooleanEnc , nme.specializedTypeNames.Boolean )
474
474
def BooleanClass (implicit ctx : Context ): ClassSymbol = BooleanType .symbol.asClass
475
475
lazy val Boolean_notR : TermRef = BooleanClass .requiredMethodRef(nme.UNARY_! )
476
476
def Boolean_! : Symbol = Boolean_notR .symbol
@@ -489,13 +489,13 @@ class Definitions {
489
489
})
490
490
def Boolean_!= : Symbol = Boolean_neqeqR .symbol
491
491
492
- lazy val ByteType : TypeRef = valueTypeRef(" scala.Byte" , BoxedByteType , java.lang.Byte .TYPE , ByteEnc , nme.specializedTypeNames.Byte )
492
+ lazy val ByteType : TypeRef = valueTypeRef(" scala.Byte" , java.lang.Byte .TYPE , ByteEnc , nme.specializedTypeNames.Byte )
493
493
def ByteClass (implicit ctx : Context ): ClassSymbol = ByteType .symbol.asClass
494
- lazy val ShortType : TypeRef = valueTypeRef(" scala.Short" , BoxedShortType , java.lang.Short .TYPE , ShortEnc , nme.specializedTypeNames.Short )
494
+ lazy val ShortType : TypeRef = valueTypeRef(" scala.Short" , java.lang.Short .TYPE , ShortEnc , nme.specializedTypeNames.Short )
495
495
def ShortClass (implicit ctx : Context ): ClassSymbol = ShortType .symbol.asClass
496
- lazy val CharType : TypeRef = valueTypeRef(" scala.Char" , BoxedCharType , java.lang.Character .TYPE , CharEnc , nme.specializedTypeNames.Char )
496
+ lazy val CharType : TypeRef = valueTypeRef(" scala.Char" , java.lang.Character .TYPE , CharEnc , nme.specializedTypeNames.Char )
497
497
def CharClass (implicit ctx : Context ): ClassSymbol = CharType .symbol.asClass
498
- lazy val IntType : TypeRef = valueTypeRef(" scala.Int" , BoxedIntType , java.lang.Integer .TYPE , IntEnc , nme.specializedTypeNames.Int )
498
+ lazy val IntType : TypeRef = valueTypeRef(" scala.Int" , java.lang.Integer .TYPE , IntEnc , nme.specializedTypeNames.Int )
499
499
def IntClass (implicit ctx : Context ): ClassSymbol = IntType .symbol.asClass
500
500
lazy val Int_minusR : TermRef = IntClass .requiredMethodRef(nme.MINUS , List (IntType ))
501
501
def Int_- : Symbol = Int_minusR .symbol
@@ -511,7 +511,7 @@ class Definitions {
511
511
def Int_>= : Symbol = Int_geR .symbol
512
512
lazy val Int_leR : TermRef = IntClass .requiredMethodRef(nme.LE , List (IntType ))
513
513
def Int_<= : Symbol = Int_leR .symbol
514
- lazy val LongType : TypeRef = valueTypeRef(" scala.Long" , BoxedLongType , java.lang.Long .TYPE , LongEnc , nme.specializedTypeNames.Long )
514
+ lazy val LongType : TypeRef = valueTypeRef(" scala.Long" , java.lang.Long .TYPE , LongEnc , nme.specializedTypeNames.Long )
515
515
def LongClass (implicit ctx : Context ): ClassSymbol = LongType .symbol.asClass
516
516
lazy val Long_XOR_Long : Symbol = LongType .member(nme.XOR ).requiredSymbol(" method" , nme.XOR , LongType .denot)(
517
517
x => (x is Method ) && (x.info.firstParamTypes.head isRef defn.LongClass )
@@ -526,9 +526,9 @@ class Definitions {
526
526
lazy val Long_divR : TermRef = LongClass .requiredMethodRef(nme.DIV , List (LongType ))
527
527
def Long_/ : Symbol = Long_divR .symbol
528
528
529
- lazy val FloatType : TypeRef = valueTypeRef(" scala.Float" , BoxedFloatType , java.lang.Float .TYPE , FloatEnc , nme.specializedTypeNames.Float )
529
+ lazy val FloatType : TypeRef = valueTypeRef(" scala.Float" , java.lang.Float .TYPE , FloatEnc , nme.specializedTypeNames.Float )
530
530
def FloatClass (implicit ctx : Context ): ClassSymbol = FloatType .symbol.asClass
531
- lazy val DoubleType : TypeRef = valueTypeRef(" scala.Double" , BoxedDoubleType , java.lang.Double .TYPE , DoubleEnc , nme.specializedTypeNames.Double )
531
+ lazy val DoubleType : TypeRef = valueTypeRef(" scala.Double" , java.lang.Double .TYPE , DoubleEnc , nme.specializedTypeNames.Double )
532
532
def DoubleClass (implicit ctx : Context ): ClassSymbol = DoubleType .symbol.asClass
533
533
534
534
lazy val BoxedUnitType : TypeRef = ctx.requiredClassRef(" scala.runtime.BoxedUnit" )
@@ -1310,23 +1310,23 @@ class Definitions {
1310
1310
1311
1311
private lazy val ScalaNumericValueTypes : collection.Set [TypeRef ] = ScalaNumericValueTypeList .toSet
1312
1312
private lazy val ScalaValueTypes : collection.Set [TypeRef ] = ScalaNumericValueTypes + UnitType + BooleanType
1313
- private lazy val ScalaBoxedTypes = ScalaValueTypes map (t => boxedTypes(t.name))
1314
1313
1315
1314
val ScalaNumericValueClasses : PerRun [collection.Set [Symbol ]] = new PerRun (implicit ctx => ScalaNumericValueTypes .map(_.symbol))
1316
1315
val ScalaValueClasses : PerRun [collection.Set [Symbol ]] = new PerRun (implicit ctx => ScalaValueTypes .map(_.symbol))
1317
- val ScalaBoxedClasses : PerRun [collection.Set [Symbol ]] = new PerRun (implicit ctx => ScalaBoxedTypes .map(_.symbol))
1318
1316
1319
- private val boxedTypes = mutable.Map [TypeName , TypeRef ]()
1317
+ val ScalaBoxedClasses : PerRun [collection.Set [Symbol ]] = new PerRun (implicit ctx =>
1318
+ Set (BoxedByteClass , BoxedShortClass , BoxedCharClass , BoxedIntClass , BoxedLongClass , BoxedFloatClass , BoxedDoubleClass , BoxedUnitClass , BoxedBooleanClass )
1319
+ )
1320
+
1320
1321
private val valueTypeEnc = mutable.Map [TypeName , PrimitiveClassEnc ]()
1321
1322
private val typeTags = mutable.Map [TypeName , Name ]().withDefaultValue(nme.specializedTypeNames.Object )
1322
1323
1323
1324
// private val unboxedTypeRef = mutable.Map[TypeName, TypeRef]()
1324
1325
// private val javaTypeToValueTypeRef = mutable.Map[Class[_], TypeRef]()
1325
1326
// private val valueTypeNamesToJavaType = mutable.Map[TypeName, Class[_]]()
1326
1327
1327
- private def valueTypeRef (name : String , boxed : TypeRef , jtype : Class [_], enc : Int , tag : Name ): TypeRef = {
1328
+ private def valueTypeRef (name : String , jtype : Class [_], enc : Int , tag : Name ): TypeRef = {
1328
1329
val vcls = ctx.requiredClassRef(name)
1329
- boxedTypes(vcls.name) = boxed
1330
1330
valueTypeEnc(vcls.name) = enc
1331
1331
typeTags(vcls.name) = tag
1332
1332
// unboxedTypeRef(boxed.name) = vcls
@@ -1336,7 +1336,19 @@ class Definitions {
1336
1336
}
1337
1337
1338
1338
/** The type of the boxed class corresponding to primitive value type `tp`. */
1339
- def boxedType (tp : Type )(implicit ctx : Context ): TypeRef = boxedTypes(scalaClassName(tp))
1339
+ def boxedType (tp : Type )(implicit ctx : Context ): TypeRef = {
1340
+ val cls = tp.classSymbol
1341
+ if (cls eq ByteClass ) BoxedByteType
1342
+ else if (cls eq ShortClass ) BoxedShortType
1343
+ else if (cls eq CharClass ) BoxedCharType
1344
+ else if (cls eq IntClass ) BoxedIntType
1345
+ else if (cls eq LongClass ) BoxedLongType
1346
+ else if (cls eq FloatClass ) BoxedFloatType
1347
+ else if (cls eq DoubleClass ) BoxedDoubleType
1348
+ else if (cls eq UnitClass ) BoxedUnitType
1349
+ else if (cls eq BooleanClass ) BoxedBooleanType
1350
+ else sys.error(s " Not a primitive value type: $tp" )
1351
+ }
1340
1352
1341
1353
/** The JVM tag for `tp` if it's a primitive, `java.lang.Object` otherwise. */
1342
1354
def typeTag (tp : Type )(implicit ctx : Context ): Name = typeTags(scalaClassName(tp))
0 commit comments