JVM IR: do not use old KotlinTypeMapper when coercing inline classes
KotlinTypeMapper.mapInlineClassTypeAsDeclaration and mapUnderlyingTypeOfInlineClassType invoked mapType which is defined in descriptorBasedTypeSignatureMapping.kt and works on KotlinType. It didn't lead to any problems, other than the fact that we were constructing IrBasedClassDescriptor in JVM IR, and then KotlinType to pass it to mapType, on each call to StackValue.boxInlineClass or unboxInlineClass, which seems wasteful. Instead of this, refactor these utilities to use type markers instead, pass IrType and IrTypeMapper directly from JVM IR, and move the "static type mapper" logic (which is used only in the old backend) out of KotlinTypeMapper.
This commit is contained in:
@@ -34,6 +34,7 @@ interface TypeSystemCommonBackendContext : TypeSystemContext {
|
||||
fun TypeConstructorMarker.isInlineClass(): Boolean
|
||||
fun TypeConstructorMarker.isInnerClass(): Boolean
|
||||
fun TypeParameterMarker.getRepresentativeUpperBound(): KotlinTypeMarker
|
||||
fun KotlinTypeMarker.getUnsubstitutedUnderlyingType(): KotlinTypeMarker?
|
||||
fun KotlinTypeMarker.getSubstitutedUnderlyingType(): KotlinTypeMarker?
|
||||
|
||||
fun KotlinTypeMarker.makeNullable(): KotlinTypeMarker =
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.resolve.constants.IntegerLiteralTypeConstructor
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.*
|
||||
import org.jetbrains.kotlin.resolve.isInlineClass
|
||||
import org.jetbrains.kotlin.resolve.substitutedUnderlyingType
|
||||
import org.jetbrains.kotlin.resolve.unsubstitutedUnderlyingType
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.model.*
|
||||
import org.jetbrains.kotlin.types.typeUtil.asTypeProjection
|
||||
@@ -645,6 +646,11 @@ interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext, TypeSy
|
||||
return representativeUpperBound
|
||||
}
|
||||
|
||||
override fun KotlinTypeMarker.getUnsubstitutedUnderlyingType(): KotlinTypeMarker? {
|
||||
require(this is KotlinType, this::errorMessage)
|
||||
return unsubstitutedUnderlyingType()
|
||||
}
|
||||
|
||||
override fun KotlinTypeMarker.getSubstitutedUnderlyingType(): KotlinTypeMarker? {
|
||||
require(this is KotlinType, this::errorMessage)
|
||||
return substitutedUnderlyingType()
|
||||
|
||||
Reference in New Issue
Block a user