[FIR] KT-56612: Fully-expand types when casting bare types

^KT-56612 Fixed

Merge-request: KT-MR-8849
Merged-by: Nikolay Lunyak <Nikolay.Lunyak@jetbrains.com>
This commit is contained in:
Nikolay Lunyak
2023-02-17 09:15:59 +00:00
committed by Space Team
parent 0963bd25a8
commit 516efe77c9
13 changed files with 163 additions and 10 deletions
@@ -6,6 +6,7 @@
package org.jetbrains.kotlin.fir.types
import org.jetbrains.kotlin.fir.FirSession
import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
import org.jetbrains.kotlin.types.AbstractTypeChecker
import org.jetbrains.kotlin.types.model.KotlinTypeMarker
@@ -22,8 +23,8 @@ fun FirSession.doUnify(
targetTypeParameters: Set<FirTypeParameterSymbol>,
result: MutableMap<FirTypeParameterSymbol, ConeTypeProjection>,
): Boolean {
val originalType = originalTypeProjection.type?.lowerBoundIfFlexible()
val typeWithParameters = typeWithParametersProjection.type
val originalType = originalTypeProjection.type?.lowerBoundIfFlexible()?.fullyExpandedType(this)
val typeWithParameters = typeWithParametersProjection.type?.lowerBoundIfFlexible()?.fullyExpandedType(this)
if (originalType is ConeIntersectionType) {
val intersectionResult = mutableMapOf<FirTypeParameterSymbol, ConeTypeProjection>()
@@ -68,14 +69,6 @@ fun FirSession.doUnify(
return true
}
if (typeWithParameters is ConeFlexibleType) {
return doUnify(
originalTypeProjection,
typeWithParametersProjection.replaceType(typeWithParameters.lowerBound),
targetTypeParameters, result,
)
}
if (typeWithParameters is ConeDefinitelyNotNullType) {
return doUnify(
originalTypeProjection,