From facdbfdc110a8e48b3569bb163c734c017c16636 Mon Sep 17 00:00:00 2001 From: Nikita Bobko Date: Thu, 26 Oct 2023 01:34:21 +0200 Subject: [PATCH] [FIR, IR] Cleanup: inline functions that have only one usage in matcher/checker Review: https://jetbrains.team/p/kt/reviews/12750/timeline --- .../calls/mpp/AbstractExpectActualChecker.kt | 42 +++---------------- .../calls/mpp/AbstractExpectActualMatcher.kt | 14 +------ 2 files changed, 7 insertions(+), 49 deletions(-) diff --git a/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/mpp/AbstractExpectActualChecker.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/mpp/AbstractExpectActualChecker.kt index 0d80192dd16..98c38e2f15c 100644 --- a/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/mpp/AbstractExpectActualChecker.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/mpp/AbstractExpectActualChecker.kt @@ -88,20 +88,7 @@ object AbstractExpectActualChecker { expectClassSymbol: RegularClassSymbolMarker, actualClassLikeSymbol: ClassLikeSymbolMarker, parentSubstitutor: TypeSubstitutorMarker?, - ): ExpectActualCheckingCompatibility<*> = getClassifiersIncompatibility( - expectClassSymbol, - actualClassLikeSymbol, - parentSubstitutor, - ) - ?: ExpectActualCheckingCompatibility.Compatible - - context(ExpectActualMatchingContext<*>) - @Suppress("warnings") - private fun getClassifiersIncompatibility( - expectClassSymbol: RegularClassSymbolMarker, - actualClassLikeSymbol: ClassLikeSymbolMarker, - parentSubstitutor: TypeSubstitutorMarker?, - ): ExpectActualCheckingCompatibility.Incompatible<*>? { + ): ExpectActualCheckingCompatibility<*> { // Can't check FQ names here because nested expected class may be implemented via actual typealias's expansion with the other FQ name require(expectClassSymbol.name == actualClassLikeSymbol.name) { "This function should be invoked only for declarations with the same name: $expectClassSymbol, $actualClassLikeSymbol" @@ -110,7 +97,7 @@ object AbstractExpectActualChecker { val actualClass = when (actualClassLikeSymbol) { is RegularClassSymbolMarker -> actualClassLikeSymbol is TypeAliasSymbolMarker -> actualClassLikeSymbol.expandToRegularClass() - ?: return null // do not report extra error on erroneous typealias + ?: return ExpectActualCheckingCompatibility.Compatible // do not report extra error on erroneous typealias else -> error("Incorrect actual classifier for $expectClassSymbol: $actualClassLikeSymbol") } @@ -157,7 +144,7 @@ object AbstractExpectActualChecker { getClassScopesIncompatibility(expectClassSymbol, actualClass, substitutor)?.let { return it } - return null + return ExpectActualCheckingCompatibility.Compatible } context(ExpectActualMatchingContext<*>) @@ -313,26 +300,7 @@ object AbstractExpectActualChecker { return ExpectActualCheckingCompatibility.Compatible } - val annotationMode = expectContainingClass?.classKind == ClassKind.ANNOTATION_CLASS - return getCallablesCheckingIncompatibility( - expectDeclaration, - actualDeclaration, - annotationMode, - parentSubstitutor, - expectContainingClass, - actualContainingClass, - ) ?: ExpectActualCheckingCompatibility.Compatible - } - - context(ExpectActualMatchingContext<*>) - private fun getCallablesCheckingIncompatibility( - expectDeclaration: CallableSymbolMarker, - actualDeclaration: CallableSymbolMarker, - insideAnnotationClass: Boolean, - parentSubstitutor: TypeSubstitutorMarker?, - expectContainingClass: RegularClassSymbolMarker?, - actualContainingClass: RegularClassSymbolMarker?, - ): ExpectActualCheckingCompatibility.Incompatible<*>? { + val insideAnnotationClass = expectContainingClass?.classKind == ClassKind.ANNOTATION_CLASS val expectedTypeParameters = expectDeclaration.typeParameters val actualTypeParameters = actualDeclaration.typeParameters val expectedValueParameters = expectDeclaration.valueParameters @@ -425,7 +393,7 @@ object AbstractExpectActualChecker { else -> error("Unsupported declarations: $expectDeclaration, $actualDeclaration") } - return null + return ExpectActualCheckingCompatibility.Compatible } context(ExpectActualMatchingContext<*>) diff --git a/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/mpp/AbstractExpectActualMatcher.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/mpp/AbstractExpectActualMatcher.kt index 6046292ec61..5361fd1bdec 100644 --- a/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/mpp/AbstractExpectActualMatcher.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/mpp/AbstractExpectActualMatcher.kt @@ -170,18 +170,8 @@ object AbstractExpectActualMatcher { return ExpectActualMatchingCompatibility.MatchedSuccessfully } - val annotationMode = expectContainingClass?.classKind == ClassKind.ANNOTATION_CLASS - return getCallablesMatchingIncompatibility(expectDeclaration, actualDeclaration, annotationMode, parentSubstitutor) - ?: ExpectActualMatchingCompatibility.MatchedSuccessfully - } + val insideAnnotationClass = expectContainingClass?.classKind == ClassKind.ANNOTATION_CLASS - context(ExpectActualMatchingContext<*>) - private fun getCallablesMatchingIncompatibility( - expectDeclaration: CallableSymbolMarker, - actualDeclaration: CallableSymbolMarker, - insideAnnotationClass: Boolean, - parentSubstitutor: TypeSubstitutorMarker?, - ): ExpectActualMatchingCompatibility.Mismatch? { if (expectDeclaration is FunctionSymbolMarker != actualDeclaration is FunctionSymbolMarker) { return ExpectActualMatchingCompatibility.CallableKind } @@ -228,7 +218,7 @@ object AbstractExpectActualMatcher { return ExpectActualMatchingCompatibility.FunctionTypeParameterUpperBounds } - return null + return ExpectActualMatchingCompatibility.MatchedSuccessfully } context(ExpectActualMatchingContext<*>)