diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrImplicitCastInserter.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrImplicitCastInserter.kt index 876bc35020a..60b105990f8 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrImplicitCastInserter.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrImplicitCastInserter.kt @@ -446,8 +446,4 @@ class Fir2IrImplicitCastInserter( return lowerBound.isMarkedNullable != upperBound.isMarkedNullable } } - - private fun ConeKotlinType.approximateForIrOrNull(): ConeKotlinType? { - return session.typeApproximator.approximateToSuperType(this, TypeApproximatorConfiguration.FrontendToBackendTypesApproximation) - } } diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt index 46283914669..32f12522ae7 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrTypeConverter.kt @@ -234,10 +234,7 @@ class Fir2IrTypeConverter( original.toIrType(typeOrigin).makeNotNull() } is ConeIntersectionType -> { - val approximated = session.typeApproximator.approximateToSuperType( - this, - TypeApproximatorConfiguration.FrontendToBackendTypesApproximation - )!! + val approximated = approximateForIrOrNull()!! approximated.toIrType(typeOrigin) } is ConeStubType -> createErrorType() @@ -362,3 +359,8 @@ fun ConeKotlinType.toIrType( with(typeConverter) { toIrType(typeOrigin) } + +context(Fir2IrComponents) +internal fun ConeKotlinType.approximateForIrOrNull(): ConeKotlinType? { + return session.typeApproximator.approximateToSuperType(this, TypeApproximatorConfiguration.FrontendToBackendTypesApproximation) +}