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