From 5be8778b449980fd2988278c8ddfd6654ee92121 Mon Sep 17 00:00:00 2001 From: Nikita Bobko Date: Mon, 30 Oct 2023 14:32:46 +0100 Subject: [PATCH] [FIR] Cleanup ClassScopes reporting The cleanup became possible after KT-62590 Review: https://jetbrains.team/p/kt/reviews/12750/timeline incompatibility.allMismatches() always returns true for mismatchedMembers => hasSingleActualSuspect always returns false => filterNot doesn't have any effect incompatibility.allMismatches() always returns false for incompatibleMembers => incompatibility.allMismatches() is redundant --- .../declaration/FirExpectActualDeclarationChecker.kt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirExpectActualDeclarationChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirExpectActualDeclarationChecker.kt index b3c218342df..003601cdb42 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirExpectActualDeclarationChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirExpectActualDeclarationChecker.kt @@ -166,23 +166,21 @@ object FirExpectActualDeclarationChecker : FirBasicDeclarationChecker() { // This is needed only to reduce the number of errors. Incompatibility errors for those members will be reported // later when this checker is called for them fun hasSingleActualSuspect( - expectedWithIncompatibility: Pair, Map>, Collection>>>, + expectedWithIncompatibility: Pair, Map>, Collection>>>, ): Boolean { val (expectedMember, incompatibility) = expectedWithIncompatibility val actualMember = incompatibility.values.singleOrNull()?.singleOrNull() @OptIn(SymbolInternals::class) return actualMember != null && - !incompatibility.allMismatches() && actualMember.fir.expectForActual?.values?.singleOrNull()?.singleOrNull() == expectedMember } val nonTrivialIncompatibleMembers = checkingCompatibility.incompatibleMembers.filterNot(::hasSingleActualSuspect) - val nonTrivialMismatchedMembers = checkingCompatibility.mismatchedMembers.filterNot(::hasSingleActualSuspect) if (nonTrivialIncompatibleMembers.isNotEmpty()) { reporter.reportOn(source, FirErrors.NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS, symbol, nonTrivialIncompatibleMembers, context) - } else if (nonTrivialMismatchedMembers.isNotEmpty()) { - reporter.reportOn(source, FirErrors.NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS, symbol, nonTrivialMismatchedMembers, context) + } else if (checkingCompatibility.mismatchedMembers.isNotEmpty()) { + reporter.reportOn(source, FirErrors.NO_ACTUAL_CLASS_MEMBER_FOR_EXPECTED_CLASS, symbol, checkingCompatibility.mismatchedMembers, context) } }