[FIR, IR] 1/2 Minimize usages of ExpectActualCompatibility, MismatchOrIncompatible and MatchedOrCompatible
- Migrate ExpectActualCompatibility -> ExpectActualCheckingCompatibility where the "checker" is expect - Migrate ExpectActualCompatibility -> ExpectActualMatchingCompatibility where the "matching" is expect KT-62590 in progress. A lot of tests start to fail now. I will fix them in next commits Review: https://jetbrains.team/p/kt/reviews/12750/timeline
This commit is contained in:
+2
-16
@@ -20,9 +20,6 @@ sealed interface ExpectActualCompatibility<out D> {
|
||||
sealed interface MismatchOrIncompatible<out D> : ExpectActualCompatibility<D> {
|
||||
val reason: String?
|
||||
}
|
||||
|
||||
// It's temporary class. KT-62590 is in progress
|
||||
sealed interface MatchedOrCompatible<out D> : ExpectActualCompatibility<D>
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -41,7 +38,7 @@ sealed class ExpectActualMatchingCompatibility : ExpectActualCompatibility<Nothi
|
||||
object FunctionTypeParameterCount : Mismatch(TYPE_PARAMETER_COUNT)
|
||||
object ParameterTypes : Mismatch("parameter types are different")
|
||||
object FunctionTypeParameterUpperBounds : Mismatch("upper bounds of type parameters are different")
|
||||
object MatchedSuccessfully : ExpectActualMatchingCompatibility(), ExpectActualCompatibility.MatchedOrCompatible<Nothing>
|
||||
object MatchedSuccessfully : ExpectActualMatchingCompatibility()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -96,16 +93,5 @@ sealed class ExpectActualCheckingCompatibility<out D> : ExpectActualCompatibilit
|
||||
object ClassTypeParameterUpperBounds : Incompatible<Nothing>(ExpectActualMatchingCompatibility.FunctionTypeParameterUpperBounds.reason)
|
||||
object TypeParameterVariance : Incompatible<Nothing>("declaration-site variances of type parameters are different")
|
||||
object TypeParameterReified : Incompatible<Nothing>("some type parameter is reified in one declaration and non-reified in the other")
|
||||
object Compatible : ExpectActualCheckingCompatibility<Nothing>(), ExpectActualCompatibility.MatchedOrCompatible<Nothing>
|
||||
object Compatible : ExpectActualCheckingCompatibility<Nothing>()
|
||||
}
|
||||
|
||||
val ExpectActualCompatibility<*>.isCompatibleOrWeaklyIncompatible: Boolean
|
||||
get() = this is ExpectActualCompatibility.MatchedOrCompatible || this is ExpectActualCheckingCompatibility
|
||||
|
||||
val ExpectActualCompatibility<*>.compatible: Boolean
|
||||
get() = this is ExpectActualCompatibility.MatchedOrCompatible
|
||||
|
||||
// It's temporary function. KT-62590 is in progress
|
||||
fun <T, R> Map<ExpectActualCompatibility<R>, List<T>>.getMatchedAndChecked(): List<T>? =
|
||||
(get(ExpectActualMatchingCompatibility.MatchedSuccessfully).orEmpty() + get(ExpectActualCheckingCompatibility.Compatible).orEmpty())
|
||||
.takeIf { it.isNotEmpty() }
|
||||
|
||||
+1
-10
@@ -56,16 +56,7 @@ data class ExpectActualMemberDiff<out M, out C>(val kind: Kind, val actualMember
|
||||
}
|
||||
}
|
||||
|
||||
fun ExpectActualCompatibility.MismatchOrIncompatible<*>.toMemberDiffKind(): ExpectActualMemberDiff.Kind? = when (this) {
|
||||
ExpectActualMatchingCompatibility.CallableKind,
|
||||
ExpectActualMatchingCompatibility.ParameterCount,
|
||||
ExpectActualMatchingCompatibility.ParameterShape,
|
||||
ExpectActualMatchingCompatibility.ParameterTypes,
|
||||
ExpectActualMatchingCompatibility.FunctionTypeParameterCount,
|
||||
ExpectActualMatchingCompatibility.FunctionTypeParameterUpperBounds,
|
||||
// It's an awful API. It will be fixed in KT-62752
|
||||
-> error("It's not allowed to call this function with receiver: $this")
|
||||
|
||||
fun ExpectActualCheckingCompatibility.Incompatible<*>.toMemberDiffKind(): ExpectActualMemberDiff.Kind? = when (this) {
|
||||
ExpectActualCheckingCompatibility.ReturnType -> ExpectActualMemberDiff.Kind.ReturnTypeChangedInOverride
|
||||
ExpectActualCheckingCompatibility.ClassTypeParameterCount -> error("Not applicable because ExpectActualMemberDiff is about members")
|
||||
ExpectActualCheckingCompatibility.ClassTypeParameterUpperBounds -> error("Not applicable because ExpectActualMemberDiff is about members")
|
||||
|
||||
Reference in New Issue
Block a user