Make IrTypeMapper delegate to AbstractTypeMapper
This commit is contained in:
+18
-8
@@ -14,15 +14,15 @@ import org.jetbrains.kotlin.resolve.jvm.AsmTypes
|
||||
import org.jetbrains.kotlin.types.model.*
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
|
||||
interface TypeMappingContext {
|
||||
interface TypeMappingContext<Writer : JvmDescriptorTypeWriter<Type>> {
|
||||
val typeContext: TypeSystemCommonBackendContextForTypeMapping
|
||||
|
||||
fun getClassInternalName(typeConstructor: TypeConstructorMarker): String
|
||||
fun JvmDescriptorTypeWriter<Type>.writeGenericType(type: SimpleTypeMarker, asmType: Type, mode: TypeMappingMode)
|
||||
fun Writer.writeGenericType(type: SimpleTypeMarker, asmType: Type, mode: TypeMappingMode)
|
||||
}
|
||||
|
||||
object AbstractTypeMapper {
|
||||
fun mapClass(context: TypeMappingContext, typeConstructor: TypeConstructorMarker): Type {
|
||||
fun <Writer : JvmDescriptorTypeWriter<Type>> mapClass(context: TypeMappingContext<Writer>, typeConstructor: TypeConstructorMarker): Type {
|
||||
return with(context.typeContext) {
|
||||
when {
|
||||
typeConstructor.isClassTypeConstructor() -> {
|
||||
@@ -36,13 +36,23 @@ object AbstractTypeMapper {
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
fun TypeSystemCommonBackendContextForTypeMapping.mapType(
|
||||
context: TypeMappingContext,
|
||||
type: SimpleTypeMarker,
|
||||
fun <Writer : JvmDescriptorTypeWriter<Type>> mapType(
|
||||
context: TypeMappingContext<Writer>,
|
||||
type: KotlinTypeMarker,
|
||||
mode: TypeMappingMode = TypeMappingMode.DEFAULT,
|
||||
sw: JvmDescriptorTypeWriter<Type>? = null
|
||||
sw: Writer? = null
|
||||
): Type = context.typeContext.mapType(context, type, mode, sw)
|
||||
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
private fun <Writer : JvmDescriptorTypeWriter<Type>> TypeSystemCommonBackendContextForTypeMapping.mapType(
|
||||
context: TypeMappingContext<Writer>,
|
||||
type: KotlinTypeMarker,
|
||||
mode: TypeMappingMode = TypeMappingMode.DEFAULT,
|
||||
sw: Writer? = null
|
||||
): Type {
|
||||
if (type !is SimpleTypeMarker) {
|
||||
error("Unexpected type: $type (original Kotlin type=$type of ${type.let { it::class }})")
|
||||
}
|
||||
if (type.isSuspendFunction()) {
|
||||
val argumentsCount = type.argumentsCount()
|
||||
val argumentsList = type.asArgumentList()
|
||||
|
||||
+2
-2
@@ -53,7 +53,7 @@ interface TypeSystemCommonBackendContext : TypeSystemContext {
|
||||
|
||||
interface TypeSystemCommonBackendContextForTypeMapping : TypeSystemCommonBackendContext {
|
||||
fun TypeConstructorMarker.isTypeParameter(): Boolean
|
||||
fun TypeConstructorMarker.defaultType(): SimpleTypeMarker
|
||||
fun TypeConstructorMarker.defaultType(): KotlinTypeMarker
|
||||
|
||||
fun SimpleTypeMarker.isSuspendFunction(): Boolean
|
||||
fun SimpleTypeMarker.isKClass(): Boolean
|
||||
@@ -70,7 +70,7 @@ interface TypeSystemCommonBackendContextForTypeMapping : TypeSystemCommonBackend
|
||||
return getType()
|
||||
}
|
||||
|
||||
fun TypeParameterMarker.representativeUpperBound(): SimpleTypeMarker
|
||||
fun TypeParameterMarker.representativeUpperBound(): KotlinTypeMarker
|
||||
|
||||
fun continuationTypeConstructor(): TypeConstructorMarker
|
||||
fun functionNTypeConstructor(n: Int): TypeConstructorMarker
|
||||
|
||||
Reference in New Issue
Block a user