@@ -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,11 +1310,25 @@ 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))
1316
+
1317
+ private lazy val ScalaBoxedTypes : SimpleIdentityMap [Symbol , TypeRef ] =
1318
+ SimpleIdentityMap .Empty [Symbol ]
1319
+ .updated(ByteClass , BoxedByteType )
1320
+ .updated(ShortClass , BoxedShortType )
1321
+ .updated(CharClass , BoxedCharType )
1322
+ .updated(IntClass , BoxedIntType )
1323
+ .updated(LongClass , BoxedLongType )
1324
+ .updated(FloatClass , BoxedFloatType )
1325
+ .updated(DoubleClass , BoxedDoubleType )
1326
+ .updated(UnitClass , BoxedUnitType )
1327
+ .updated(BooleanClass , BoxedBooleanType )
1328
+
1329
+ val ScalaBoxedClasses : PerRun [collection.Set [Symbol ]] = new PerRun (implicit ctx =>
1330
+ Set (BoxedByteClass , BoxedShortClass , BoxedCharClass , BoxedIntClass , BoxedLongClass , BoxedFloatClass , BoxedDoubleClass , BoxedUnitClass , BoxedBooleanClass )
1331
+ )
1318
1332
1319
1333
private val boxedTypes = mutable.Map [TypeName , TypeRef ]()
1320
1334
private val valueTypeEnc = mutable.Map [TypeName , PrimitiveClassEnc ]()
@@ -1324,9 +1338,8 @@ class Definitions {
1324
1338
// private val javaTypeToValueTypeRef = mutable.Map[Class[_], TypeRef]()
1325
1339
// private val valueTypeNamesToJavaType = mutable.Map[TypeName, Class[_]]()
1326
1340
1327
- private def valueTypeRef (name : String , boxed : TypeRef , jtype : Class [_], enc : Int , tag : Name ): TypeRef = {
1341
+ private def valueTypeRef (name : String , jtype : Class [_], enc : Int , tag : Name ): TypeRef = {
1328
1342
val vcls = ctx.requiredClassRef(name)
1329
- boxedTypes(vcls.name) = boxed
1330
1343
valueTypeEnc(vcls.name) = enc
1331
1344
typeTags(vcls.name) = tag
1332
1345
// unboxedTypeRef(boxed.name) = vcls
@@ -1336,7 +1349,7 @@ class Definitions {
1336
1349
}
1337
1350
1338
1351
/** The type of the boxed class corresponding to primitive value type `tp`. */
1339
- def boxedType (tp : Type )(implicit ctx : Context ): TypeRef = boxedTypes(scalaClassName(tp) )
1352
+ def boxedType (tp : Type )(implicit ctx : Context ): TypeRef = ScalaBoxedTypes (tp.classSymbol )
1340
1353
1341
1354
/** The JVM tag for `tp` if it's a primitive, `java.lang.Object` otherwise. */
1342
1355
def typeTag (tp : Type )(implicit ctx : Context ): Name = typeTags(scalaClassName(tp))
0 commit comments