From fd5e97ff23581685c4ad315cf476cdc3120dd9fb Mon Sep 17 00:00:00 2001 From: Nikita Bobko Date: Wed, 2 Aug 2023 18:59:54 +0200 Subject: [PATCH] [FE] Refactoring: Move check for "enumConstructorsAreAlwaysCompatible" higher than check for callable kind Review: https://jetbrains.team/p/kt/reviews/11039/timeline This is a preparation refactoring for the following KT-60902 fix and type-safety refactoring. This commit doesn't have observable side effects (and can be called pure refactoring) because the following conditions: 1. `expectDeclaration is ConstructorSymbolMarker && actualDeclaration is ConstructorSymbolMarker` 2. `expectDeclaration is FunctionSymbolMarker != actualDeclaration is FunctionSymbolMarker` can't be both `true` at the same time --- .../calls/mpp/AbstractExpectActualCompatibilityChecker.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/mpp/AbstractExpectActualCompatibilityChecker.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/mpp/AbstractExpectActualCompatibilityChecker.kt index f1a9e869e45..3001ce86e82 100644 --- a/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/mpp/AbstractExpectActualCompatibilityChecker.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/mpp/AbstractExpectActualCompatibilityChecker.kt @@ -288,10 +288,6 @@ object AbstractExpectActualCompatibilityChecker { "This function should be invoked only for declarations in the same kind of container (both members or both top level): $expectDeclaration, $actualDeclaration" } - if (expectDeclaration is FunctionSymbolMarker != actualDeclaration is FunctionSymbolMarker) { - return Incompatible.CallableKind - } - if ( enumConstructorsAreAlwaysCompatible && expectContainingClass?.classKind == ClassKind.ENUM_CLASS && @@ -302,6 +298,10 @@ object AbstractExpectActualCompatibilityChecker { return ExpectActualCompatibility.Compatible } + if (expectDeclaration is FunctionSymbolMarker != actualDeclaration is FunctionSymbolMarker) { + return Incompatible.CallableKind + } + val expectedReceiverType = expectDeclaration.extensionReceiverType val actualReceiverType = actualDeclaration.extensionReceiverType if ((expectedReceiverType != null) != (actualReceiverType != null)) {