[FIR2IR] Properly approximate intersection types during fir2ir conversion

^KT-62544 Fixed
This commit is contained in:
Dmitriy Novozhilov
2023-10-16 13:19:40 +03:00
committed by Space Team
parent 8c6da9fddb
commit 9366847e96
52 changed files with 450 additions and 803 deletions
@@ -29,17 +29,9 @@ class TypeTranslatorImpl(
private val typeApproximatorForNI = TypeApproximator(moduleDescriptor.builtIns, languageVersionSettings)
private val typeApproximatorConfiguration =
object : TypeApproximatorConfiguration.AllFlexibleSameValue() {
override val allFlexible: Boolean get() = true
override val errorType: Boolean get() = true
override val integerLiteralConstantType: Boolean get() = true
override val intersectionTypesInContravariantPositions: Boolean get() = true
}
override fun approximateType(type: KotlinType): KotlinType =
substituteAlternativesInPublicType(type).let {
typeApproximatorForNI.approximateToSuperType(it, typeApproximatorConfiguration) ?: it
typeApproximatorForNI.approximateToSuperType(it, TypeApproximatorConfiguration.FrontendToBackendTypesApproximation) ?: it
}
override fun commonSupertype(types: Collection<KotlinType>): KotlinType =