[FIR2IR] Minor: reuse approximateForIrOrNull utility in Fir2IrTypeConverter

This commit is contained in:
Dmitriy Novozhilov
2023-11-09 11:11:07 +02:00
committed by Space Team
parent 10914eb23f
commit 40f95cd5dd
2 changed files with 6 additions and 8 deletions
@@ -446,8 +446,4 @@ class Fir2IrImplicitCastInserter(
return lowerBound.isMarkedNullable != upperBound.isMarkedNullable return lowerBound.isMarkedNullable != upperBound.isMarkedNullable
} }
} }
private fun ConeKotlinType.approximateForIrOrNull(): ConeKotlinType? {
return session.typeApproximator.approximateToSuperType(this, TypeApproximatorConfiguration.FrontendToBackendTypesApproximation)
}
} }
@@ -234,10 +234,7 @@ class Fir2IrTypeConverter(
original.toIrType(typeOrigin).makeNotNull() original.toIrType(typeOrigin).makeNotNull()
} }
is ConeIntersectionType -> { is ConeIntersectionType -> {
val approximated = session.typeApproximator.approximateToSuperType( val approximated = approximateForIrOrNull()!!
this,
TypeApproximatorConfiguration.FrontendToBackendTypesApproximation
)!!
approximated.toIrType(typeOrigin) approximated.toIrType(typeOrigin)
} }
is ConeStubType -> createErrorType() is ConeStubType -> createErrorType()
@@ -362,3 +359,8 @@ fun ConeKotlinType.toIrType(
with(typeConverter) { with(typeConverter) {
toIrType(typeOrigin) toIrType(typeOrigin)
} }
context(Fir2IrComponents)
internal fun ConeKotlinType.approximateForIrOrNull(): ConeKotlinType? {
return session.typeApproximator.approximateToSuperType(this, TypeApproximatorConfiguration.FrontendToBackendTypesApproximation)
}