FIR: Fix incorrectly serialized type

See the test added: there's a non-denotable T!! type inside flexible type
that wasn't handled before.

ConeKotlinType::contains handles flexible types content and some other cases
Also, it has better asymptotics
This commit is contained in:
Denis.Zharkov
2021-01-28 18:15:15 +03:00
parent 1e0d9f4075
commit 7e6abffb62
10 changed files with 84 additions and 16 deletions
@@ -11,7 +11,6 @@ import org.jetbrains.kotlin.fir.FirFakeSourceElementKind
import org.jetbrains.kotlin.fir.FirSession
import org.jetbrains.kotlin.fir.declarations.classId
import org.jetbrains.kotlin.fir.diagnostics.ConeSimpleDiagnostic
import org.jetbrains.kotlin.fir.expressions.classId
import org.jetbrains.kotlin.fir.fakeElement
import org.jetbrains.kotlin.fir.render
import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
@@ -270,17 +269,8 @@ fun FirTypeRef.approximatedForPublicPosition(approximator: AbstractTypeApproxima
else
this
private fun ConeKotlinType.requiresApproximationInPublicPosition(): Boolean {
return when (this) {
is ConeIntegerLiteralType,
is ConeCapturedType,
is ConeDefinitelyNotNullType,
is ConeIntersectionType -> true
is ConeClassLikeType -> typeArguments.any {
it is ConeKotlinTypeProjection && it.type.requiresApproximationInPublicPosition()
}
else -> false
}
private fun ConeKotlinType.requiresApproximationInPublicPosition(): Boolean = contains {
it is ConeIntegerLiteralType || it is ConeCapturedType || it is ConeDefinitelyNotNullType || it is ConeIntersectionType
}
/*