diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt index d2b4f6849e5..42128cf96e0 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt @@ -941,7 +941,12 @@ class ExpressionCodegen( putReifiedOperationMarkerIfTypeIsReifiedParameter(classType, ReifiedTypeInliner.OperationKind.JAVA_CLASS, mv, this) } - putJavaLangClassInstance(mv, typeMapper.mapType(classType), classType.toKotlinType(), typeMapper.kotlinTypeMapper) + val asmType = typeMapper.mapType(classType) + if (classType.getClass()?.isInline == true || !isPrimitive(asmType)) { + mv.aconst(typeMapper.boxType(classType)) + } else { + mv.getstatic(boxType(asmType).internalName, "TYPE", "Ljava/lang/Class;") + } } else { throw AssertionError("not an IrGetClass or IrClassReference: ${classReference.dump()}") } diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrTypeMapper.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrTypeMapper.kt index 07458862a2a..88dbded9fb8 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrTypeMapper.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrTypeMapper.kt @@ -10,7 +10,6 @@ import org.jetbrains.kotlin.builtins.functions.FunctionClassDescriptor import org.jetbrains.kotlin.builtins.isSuspendFunctionType import org.jetbrains.kotlin.builtins.transformSuspendFunctionToRuntimeFunctionType import org.jetbrains.kotlin.codegen.AsmUtil -import org.jetbrains.kotlin.codegen.ClassBuilderMode import org.jetbrains.kotlin.codegen.JvmCodegenUtil import org.jetbrains.kotlin.codegen.signature.AsmTypeFactory import org.jetbrains.kotlin.codegen.signature.JvmSignatureWriter @@ -32,7 +31,6 @@ import org.jetbrains.kotlin.types.Variance import org.jetbrains.org.objectweb.asm.Type class IrTypeMapper(private val context: JvmBackendContext) { - val kotlinTypeMapper: KotlinTypeMapper = context.state.typeMapper private val typeSystem = IrTypeCheckerContext(context.irBuiltIns) fun classInternalName(irClass: IrClass): String = @@ -71,7 +69,7 @@ class IrTypeMapper(private val context: JvmBackendContext) { // TODO: rewrite this part to produce the correct Type without the fake descriptor if (type.toKotlinType().isSuspendFunctionType) { - return kotlinTypeMapper.mapType( + return context.state.typeMapper.mapType( transformSuspendFunctionToRuntimeFunctionType(type.toKotlinType(), isReleaseCoroutines = true), sw, mode ) } diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt index b6333632f59..6f1f8c8f721 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/MethodSignatureMapper.kt @@ -27,7 +27,7 @@ import org.jetbrains.org.objectweb.asm.commons.Method class MethodSignatureMapper(context: JvmBackendContext) { private val typeMapper: IrTypeMapper = context.typeMapper - private val kotlinTypeMapper: KotlinTypeMapper = typeMapper.kotlinTypeMapper + private val kotlinTypeMapper: KotlinTypeMapper = context.state.typeMapper fun mapAsmMethod(irFunction: IrFunction): Method = kotlinTypeMapper.mapAsmMethod(irFunction.descriptor)