[FIR] Refactor: extract function which returns single compatible expect

...symbol for actual symbol. It will be reused in next commit.

^KT-62036
This commit is contained in:
Roman Efremov
2023-09-22 15:13:50 +02:00
committed by Space Team
parent 9943c7078c
commit 2d51bb233d
2 changed files with 5 additions and 1 deletions
@@ -188,7 +188,7 @@ object FirExpectActualDeclarationChecker : FirBasicDeclarationChecker() {
else -> {}
}
// We want to report errors even if a candidate is incompatible, but it's single
val expectedSingleCandidate = compatibilityToMembersMap[Compatible]?.singleOrNull()
val expectedSingleCandidate = symbol.getSingleCompatibleExpectForActualOrNull()
?: symbol.getSingleExpectForActualOrNull()
if (expectedSingleCandidate != null) {
checkIfExpectHasDefaultArgumentsAndActualizedWithTypealias(
@@ -27,6 +27,10 @@ fun FirBasedSymbol<*>.getSingleExpectForActualOrNull(): FirBasedSymbol<*>? {
return expectForActual?.values?.singleOrNull()?.singleOrNull()
}
fun FirBasedSymbol<*>.getSingleCompatibleExpectForActualOrNull(): FirBasedSymbol<*>? {
return expectForActual?.get(ExpectActualCompatibility.Compatible)?.singleOrNull()
}
fun FirBasedSymbol<*>.getSingleCompatibleOrWeaklyIncompatibleExpectForActualOrNull(): FirBasedSymbol<*>? {
val expectForActual = expectForActual ?: return null
val compatibleOrWeakCompatible: List<FirBasedSymbol<*>> =