[FIR, IR] Check for strict subtypes during actualization

^KT-65775 Fixed
Review: https://jetbrains.team/p/kt/reviews/14906/timeline
This commit is contained in:
Nikita Bobko
2024-03-12 17:34:47 +01:00
committed by Space Team
parent 0fec50135f
commit a8275c99a3
12 changed files with 102 additions and 16 deletions
@@ -165,10 +165,9 @@ object AbstractExpectActualChecker {
val expectSupertypes = expectClassSymbol.superTypes.filterNot { it.typeConstructor().isAnyConstructor() }
val actualType = actualClassSymbol.defaultType
return expectSupertypes.all { expectSupertype ->
actualTypeIsSubtypeOfExpectType(
expectType = substitutor.safeSubstitute(expectSupertype),
actualType = actualType
)
val expectType = substitutor.safeSubstitute(expectSupertype)
isSubtypeOf(superType = expectType, subType = actualType) &&
!isSubtypeOf(superType = actualType, subType = expectType)
}
}
@@ -131,9 +131,9 @@ interface ExpectActualMatchingContext<T : DeclarationSymbolMarker> : TypeSystemC
dynamicTypesEqualToAnything: Boolean = true
): Boolean
fun actualTypeIsSubtypeOfExpectType(
expectType: KotlinTypeMarker,
actualType: KotlinTypeMarker
fun isSubtypeOf(
superType: KotlinTypeMarker,
subType: KotlinTypeMarker
): Boolean
fun RegularClassSymbolMarker.isNotSamInterface(): Boolean