PSI2IR/FIR2IR: do not approximate T!! before translation
This leads to weird effects when it's in a contravariant position, because it's approximated by Nothing.
This commit is contained in:
@@ -67,6 +67,14 @@ class Fir2IrTypeConverter(
|
||||
|
||||
private val typeApproximator = ConeTypeApproximator(session.typeContext, session.languageVersionSettings)
|
||||
|
||||
private val typeApproximatorConfiguration =
|
||||
object : TypeApproximatorConfiguration.AllFlexibleSameValue() {
|
||||
override val allFlexible: Boolean get() = true
|
||||
override val errorType: Boolean get() = true
|
||||
override val integerLiteralType: Boolean get() = true
|
||||
override val intersectionTypesInContravariantPositions: Boolean get() = true
|
||||
}
|
||||
|
||||
fun FirTypeRef.toIrType(typeContext: ConversionTypeContext = ConversionTypeContext.DEFAULT): IrType {
|
||||
capturedTypeCache.clear()
|
||||
return when (this) {
|
||||
@@ -232,11 +240,9 @@ class Fir2IrTypeConverter(
|
||||
} else null
|
||||
}
|
||||
}
|
||||
val typeWithSpecifiedIntersectionTypes = substitutor.substituteOrSelf(type)
|
||||
return typeApproximator.approximateToSuperType(
|
||||
typeWithSpecifiedIntersectionTypes,
|
||||
TypeApproximatorConfiguration.PublicDeclaration
|
||||
) ?: type
|
||||
return substitutor.substituteOrSelf(type).let {
|
||||
typeApproximator.approximateToSuperType(it, typeApproximatorConfiguration) ?: it
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user