@@ -470,10 +470,10 @@ class Definitions {
470
470
def ArrayModule (implicit ctx : Context ): ClassSymbol = ArrayModuleType .symbol.moduleClass.asClass
471
471
472
472
473
- lazy val UnitType : TypeRef = valueTypeRef(" scala.Unit" , BoxedUnitType , java.lang.Void .TYPE , UnitEnc , nme.specializedTypeNames.Void )
473
+ lazy val UnitType : TypeRef = valueTypeRef(" scala.Unit" , java.lang.Void .TYPE , UnitEnc , nme.specializedTypeNames.Void )
474
474
def UnitClass (implicit ctx : Context ): ClassSymbol = UnitType .symbol.asClass
475
475
def UnitModuleClass (implicit ctx : Context ): Symbol = UnitType .symbol.asClass.linkedClass
476
- lazy val BooleanType : TypeRef = valueTypeRef(" scala.Boolean" , BoxedBooleanType , java.lang.Boolean .TYPE , BooleanEnc , nme.specializedTypeNames.Boolean )
476
+ lazy val BooleanType : TypeRef = valueTypeRef(" scala.Boolean" , java.lang.Boolean .TYPE , BooleanEnc , nme.specializedTypeNames.Boolean )
477
477
def BooleanClass (implicit ctx : Context ): ClassSymbol = BooleanType .symbol.asClass
478
478
lazy val Boolean_notR : TermRef = BooleanClass .requiredMethodRef(nme.UNARY_! )
479
479
def Boolean_! : Symbol = Boolean_notR .symbol
@@ -492,13 +492,13 @@ class Definitions {
492
492
})
493
493
def Boolean_!= : Symbol = Boolean_neqeqR .symbol
494
494
495
- lazy val ByteType : TypeRef = valueTypeRef(" scala.Byte" , BoxedByteType , java.lang.Byte .TYPE , ByteEnc , nme.specializedTypeNames.Byte )
495
+ lazy val ByteType : TypeRef = valueTypeRef(" scala.Byte" , java.lang.Byte .TYPE , ByteEnc , nme.specializedTypeNames.Byte )
496
496
def ByteClass (implicit ctx : Context ): ClassSymbol = ByteType .symbol.asClass
497
- lazy val ShortType : TypeRef = valueTypeRef(" scala.Short" , BoxedShortType , java.lang.Short .TYPE , ShortEnc , nme.specializedTypeNames.Short )
497
+ lazy val ShortType : TypeRef = valueTypeRef(" scala.Short" , java.lang.Short .TYPE , ShortEnc , nme.specializedTypeNames.Short )
498
498
def ShortClass (implicit ctx : Context ): ClassSymbol = ShortType .symbol.asClass
499
- lazy val CharType : TypeRef = valueTypeRef(" scala.Char" , BoxedCharType , java.lang.Character .TYPE , CharEnc , nme.specializedTypeNames.Char )
499
+ lazy val CharType : TypeRef = valueTypeRef(" scala.Char" , java.lang.Character .TYPE , CharEnc , nme.specializedTypeNames.Char )
500
500
def CharClass (implicit ctx : Context ): ClassSymbol = CharType .symbol.asClass
501
- lazy val IntType : TypeRef = valueTypeRef(" scala.Int" , BoxedIntType , java.lang.Integer .TYPE , IntEnc , nme.specializedTypeNames.Int )
501
+ lazy val IntType : TypeRef = valueTypeRef(" scala.Int" , java.lang.Integer .TYPE , IntEnc , nme.specializedTypeNames.Int )
502
502
def IntClass (implicit ctx : Context ): ClassSymbol = IntType .symbol.asClass
503
503
lazy val Int_minusR : TermRef = IntClass .requiredMethodRef(nme.MINUS , List (IntType ))
504
504
def Int_- : Symbol = Int_minusR .symbol
@@ -514,7 +514,7 @@ class Definitions {
514
514
def Int_>= : Symbol = Int_geR .symbol
515
515
lazy val Int_leR : TermRef = IntClass .requiredMethodRef(nme.LE , List (IntType ))
516
516
def Int_<= : Symbol = Int_leR .symbol
517
- lazy val LongType : TypeRef = valueTypeRef(" scala.Long" , BoxedLongType , java.lang.Long .TYPE , LongEnc , nme.specializedTypeNames.Long )
517
+ lazy val LongType : TypeRef = valueTypeRef(" scala.Long" , java.lang.Long .TYPE , LongEnc , nme.specializedTypeNames.Long )
518
518
def LongClass (implicit ctx : Context ): ClassSymbol = LongType .symbol.asClass
519
519
lazy val Long_XOR_Long : Symbol = LongType .member(nme.XOR ).requiredSymbol(" method" , nme.XOR , LongType .denot)(
520
520
x => (x is Method ) && (x.info.firstParamTypes.head isRef defn.LongClass )
@@ -529,9 +529,9 @@ class Definitions {
529
529
lazy val Long_divR : TermRef = LongClass .requiredMethodRef(nme.DIV , List (LongType ))
530
530
def Long_/ : Symbol = Long_divR .symbol
531
531
532
- lazy val FloatType : TypeRef = valueTypeRef(" scala.Float" , BoxedFloatType , java.lang.Float .TYPE , FloatEnc , nme.specializedTypeNames.Float )
532
+ lazy val FloatType : TypeRef = valueTypeRef(" scala.Float" , java.lang.Float .TYPE , FloatEnc , nme.specializedTypeNames.Float )
533
533
def FloatClass (implicit ctx : Context ): ClassSymbol = FloatType .symbol.asClass
534
- lazy val DoubleType : TypeRef = valueTypeRef(" scala.Double" , BoxedDoubleType , java.lang.Double .TYPE , DoubleEnc , nme.specializedTypeNames.Double )
534
+ lazy val DoubleType : TypeRef = valueTypeRef(" scala.Double" , java.lang.Double .TYPE , DoubleEnc , nme.specializedTypeNames.Double )
535
535
def DoubleClass (implicit ctx : Context ): ClassSymbol = DoubleType .symbol.asClass
536
536
537
537
lazy val BoxedUnitType : TypeRef = ctx.requiredClassRef(" scala.runtime.BoxedUnit" )
@@ -1361,23 +1361,23 @@ class Definitions {
1361
1361
1362
1362
private lazy val ScalaNumericValueTypes : collection.Set [TypeRef ] = ScalaNumericValueTypeList .toSet
1363
1363
private lazy val ScalaValueTypes : collection.Set [TypeRef ] = ScalaNumericValueTypes + UnitType + BooleanType
1364
- private lazy val ScalaBoxedTypes = ScalaValueTypes map (t => boxedTypes(t.name))
1365
1364
1366
1365
val ScalaNumericValueClasses : PerRun [collection.Set [Symbol ]] = new PerRun (implicit ctx => ScalaNumericValueTypes .map(_.symbol))
1367
1366
val ScalaValueClasses : PerRun [collection.Set [Symbol ]] = new PerRun (implicit ctx => ScalaValueTypes .map(_.symbol))
1368
- val ScalaBoxedClasses : PerRun [collection.Set [Symbol ]] = new PerRun (implicit ctx => ScalaBoxedTypes .map(_.symbol))
1369
1367
1370
- private val boxedTypes = mutable.Map [TypeName , TypeRef ]()
1368
+ val ScalaBoxedClasses : PerRun [collection.Set [Symbol ]] = new PerRun (implicit ctx =>
1369
+ Set (BoxedByteClass , BoxedShortClass , BoxedCharClass , BoxedIntClass , BoxedLongClass , BoxedFloatClass , BoxedDoubleClass , BoxedUnitClass , BoxedBooleanClass )
1370
+ )
1371
+
1371
1372
private val valueTypeEnc = mutable.Map [TypeName , PrimitiveClassEnc ]()
1372
1373
private val typeTags = mutable.Map [TypeName , Name ]().withDefaultValue(nme.specializedTypeNames.Object )
1373
1374
1374
1375
// private val unboxedTypeRef = mutable.Map[TypeName, TypeRef]()
1375
1376
// private val javaTypeToValueTypeRef = mutable.Map[Class[_], TypeRef]()
1376
1377
// private val valueTypeNamesToJavaType = mutable.Map[TypeName, Class[_]]()
1377
1378
1378
- private def valueTypeRef (name : String , boxed : TypeRef , jtype : Class [_], enc : Int , tag : Name ): TypeRef = {
1379
+ private def valueTypeRef (name : String , jtype : Class [_], enc : Int , tag : Name ): TypeRef = {
1379
1380
val vcls = ctx.requiredClassRef(name)
1380
- boxedTypes(vcls.name) = boxed
1381
1381
valueTypeEnc(vcls.name) = enc
1382
1382
typeTags(vcls.name) = tag
1383
1383
// unboxedTypeRef(boxed.name) = vcls
@@ -1387,7 +1387,19 @@ class Definitions {
1387
1387
}
1388
1388
1389
1389
/** The type of the boxed class corresponding to primitive value type `tp`. */
1390
- def boxedType (tp : Type )(implicit ctx : Context ): TypeRef = boxedTypes(scalaClassName(tp))
1390
+ def boxedType (tp : Type )(implicit ctx : Context ): TypeRef = {
1391
+ val cls = tp.classSymbol
1392
+ if (cls eq ByteClass ) BoxedByteType
1393
+ else if (cls eq ShortClass ) BoxedShortType
1394
+ else if (cls eq CharClass ) BoxedCharType
1395
+ else if (cls eq IntClass ) BoxedIntType
1396
+ else if (cls eq LongClass ) BoxedLongType
1397
+ else if (cls eq FloatClass ) BoxedFloatType
1398
+ else if (cls eq DoubleClass ) BoxedDoubleType
1399
+ else if (cls eq UnitClass ) BoxedUnitType
1400
+ else if (cls eq BooleanClass ) BoxedBooleanType
1401
+ else sys.error(s " Not a primitive value type: $tp" )
1402
+ }
1391
1403
1392
1404
/** The JVM tag for `tp` if it's a primitive, `java.lang.Object` otherwise. */
1393
1405
def typeTag (tp : Type )(implicit ctx : Context ): Name = typeTags(scalaClassName(tp))
0 commit comments