File tree Expand file tree Collapse file tree 3 files changed +14
-16
lines changed Expand file tree Collapse file tree 3 files changed +14
-16
lines changed Original file line number Diff line number Diff line change @@ -512,9 +512,16 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
512
512
513
513
case ClazzTag =>
514
514
val tp = toTypeKind(const.typeValue)
515
- // classOf[Int] is transformed to Integer.TYPE by ClassOf
516
- assert(! tp.isPrimitive, s " expected class type in classOf[T], found primitive type $tp" )
517
- mnode.visitLdcInsn(tp.toASMType)
515
+ if tp.isPrimitive then
516
+ val boxedClass = boxedClassOfPrimitive(tp.asPrimitiveBType)
517
+ mnode.visitFieldInsn(
518
+ asm.Opcodes .GETSTATIC ,
519
+ boxedClass.internalName,
520
+ " TYPE" , // field name
521
+ jlClassRef.descriptor
522
+ )
523
+ else
524
+ mnode.visitLdcInsn(tp.toASMType)
518
525
519
526
case EnumTag =>
520
527
val sym = const.symbolValue
Original file line number Diff line number Diff line change @@ -124,6 +124,7 @@ class CoreBTypes[BTFS <: BTypesFromSymbols[_ <: DottyBackendInterface]](val bTyp
124
124
lazy val jlStringBuilderRef : ClassBType = classBTypeFromSymbol(requiredClass[java.lang.StringBuilder ])
125
125
lazy val jlStringBufferRef : ClassBType = classBTypeFromSymbol(requiredClass[java.lang.StringBuffer ])
126
126
lazy val jlCharSequenceRef : ClassBType = classBTypeFromSymbol(requiredClass[java.lang.CharSequence ])
127
+ lazy val jlClassRef : ClassBType = classBTypeFromSymbol(requiredClass[java.lang.Class [_]])
127
128
lazy val ThrowableReference : ClassBType = classBTypeFromSymbol(defn.ThrowableClass )
128
129
lazy val jlCloneableReference : ClassBType = classBTypeFromSymbol(defn.JavaCloneableClass ) // java/lang/Cloneable
129
130
lazy val jlNPEReference : ClassBType = classBTypeFromSymbol(defn.NullPointerExceptionClass ) // java/lang/NullPointerException
@@ -248,6 +249,7 @@ final class CoreBTypesProxy[BTFS <: BTypesFromSymbols[_ <: DottyBackendInterface
248
249
def jlStringBuilderRef : ClassBType = _coreBTypes.jlStringBuilderRef
249
250
def jlStringBufferRef : ClassBType = _coreBTypes.jlStringBufferRef
250
251
def jlCharSequenceRef : ClassBType = _coreBTypes.jlCharSequenceRef
252
+ def jlClassRef : ClassBType = _coreBTypes.jlClassRef
251
253
def ThrowableReference : ClassBType = _coreBTypes.ThrowableReference
252
254
def jlCloneableReference : ClassBType = _coreBTypes.jlCloneableReference
253
255
def jlNPEReference : ClassBType = _coreBTypes.jlNPEReference
Original file line number Diff line number Diff line change @@ -1157,19 +1157,8 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
1157
1157
/** A tree that corresponds to `Predef.classOf[$tp]` in source */
1158
1158
def clsOf (tp : Type )(using Context ): Tree =
1159
1159
if ctx.erasedTypes then
1160
- def TYPE (module : TermSymbol ) = ref(module).select(nme.TYPE_ )
1161
- defn.scalaClassName(tp) match
1162
- case tpnme.Boolean => TYPE (defn.BoxedBooleanModule )
1163
- case tpnme.Byte => TYPE (defn.BoxedByteModule )
1164
- case tpnme.Short => TYPE (defn.BoxedShortModule )
1165
- case tpnme.Char => TYPE (defn.BoxedCharModule )
1166
- case tpnme.Int => TYPE (defn.BoxedIntModule )
1167
- case tpnme.Long => TYPE (defn.BoxedLongModule )
1168
- case tpnme.Float => TYPE (defn.BoxedFloatModule )
1169
- case tpnme.Double => TYPE (defn.BoxedDoubleModule )
1170
- case tpnme.Unit => TYPE (defn.BoxedUnitModule )
1171
- case _ =>
1172
- Literal (Constant (TypeErasure .erasure(tp)))
1160
+ if tp.isRef(defn.UnitClass ) then Literal (Constant (tp))
1161
+ else Literal (Constant (TypeErasure .erasure(tp)))
1173
1162
else
1174
1163
Literal (Constant (tp))
1175
1164
You can’t perform that action at this time.
0 commit comments