JVM IR: do not use AsmUtil.putJavaLangClassInstance

To get rid of the last external usage of IrTypeMapper.kotlinTypeMapper
This commit is contained in:
Alexander Udalov
2019-08-23 19:07:19 +02:00
parent 23eb6daae9
commit fec8dbf6df
3 changed files with 8 additions and 5 deletions
@@ -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()}")
}
@@ -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
)
}
@@ -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)