From 3124cbcbad3bfef409be1e237fd12b963ea2623e Mon Sep 17 00:00:00 2001 From: Roman Efremov Date: Wed, 23 Aug 2023 09:50:00 +0200 Subject: [PATCH] [FE, IR] Refactor: rename areAnnotationArgumentsEqual parameters Rename to "expect" and "actual" annotation. This will be needed in next commit to make it clear that only expect annotation value needs special handling. ^KTIJ-26700 --- .../mpp/FirExpectActualMatchingContextImpl.kt | 6 ++--- .../IrExpectActualMatchingContext.kt | 6 ++--- .../calls/mpp/ExpectActualMatchingContext.kt | 4 +-- .../ClassicExpectActualMatchingContext.kt | 8 +++--- .../constExpressionValuesEqualityChecker.kt | 26 +++++++++---------- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/mpp/FirExpectActualMatchingContextImpl.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/mpp/FirExpectActualMatchingContextImpl.kt index 555f3d5dc3d..9341c9ba6b5 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/mpp/FirExpectActualMatchingContextImpl.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/mpp/FirExpectActualMatchingContextImpl.kt @@ -343,14 +343,14 @@ class FirExpectActualMatchingContextImpl private constructor( get() = asSymbol().resolvedAnnotationsWithArguments.map(::AnnotationCallInfoImpl) override fun areAnnotationArgumentsEqual( - annotation1: AnnotationCallInfo, - annotation2: AnnotationCallInfo, + expectAnnotation: AnnotationCallInfo, + actualAnnotation: AnnotationCallInfo, collectionArgumentsCompatibilityCheckStrategy: ExpectActualCollectionArgumentsCompatibilityCheckStrategy, ): Boolean { fun AnnotationCallInfo.getFirAnnotation(): FirAnnotation { return (this as AnnotationCallInfoImpl).annotation } - return areFirAnnotationsEqual(annotation1.getFirAnnotation(), annotation2.getFirAnnotation()) + return areFirAnnotationsEqual(expectAnnotation.getFirAnnotation(), actualAnnotation.getFirAnnotation()) } private fun areFirAnnotationsEqual(annotation1: FirAnnotation, annotation2: FirAnnotation): Boolean { diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/actualizer/IrExpectActualMatchingContext.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/actualizer/IrExpectActualMatchingContext.kt index 5dccfd2cd45..802ae5054b1 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/actualizer/IrExpectActualMatchingContext.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/actualizer/IrExpectActualMatchingContext.kt @@ -472,14 +472,14 @@ internal abstract class IrExpectActualMatchingContext( get() = asIr().annotations.map(::AnnotationCallInfoImpl) override fun areAnnotationArgumentsEqual( - annotation1: AnnotationCallInfo, annotation2: AnnotationCallInfo, + expectAnnotation: AnnotationCallInfo, actualAnnotation: AnnotationCallInfo, collectionArgumentsCompatibilityCheckStrategy: ExpectActualCollectionArgumentsCompatibilityCheckStrategy, ): Boolean { fun AnnotationCallInfo.getIrElement(): IrConstructorCall = (this as AnnotationCallInfoImpl).irElement return areIrExpressionConstValuesEqual( - annotation1.getIrElement(), - annotation2.getIrElement(), + expectAnnotation.getIrElement(), + actualAnnotation.getIrElement(), collectionArgumentsCompatibilityCheckStrategy, ) } diff --git a/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/mpp/ExpectActualMatchingContext.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/mpp/ExpectActualMatchingContext.kt index b1d17171544..5bc4d296212 100644 --- a/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/mpp/ExpectActualMatchingContext.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/mpp/ExpectActualMatchingContext.kt @@ -177,8 +177,8 @@ interface ExpectActualMatchingContext : TypeSystemC val DeclarationSymbolMarker.annotations: List fun areAnnotationArgumentsEqual( - annotation1: AnnotationCallInfo, - annotation2: AnnotationCallInfo, + expectAnnotation: AnnotationCallInfo, + actualAnnotation: AnnotationCallInfo, collectionArgumentsCompatibilityCheckStrategy: ExpectActualCollectionArgumentsCompatibilityCheckStrategy, ): Boolean diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/multiplatform/ClassicExpectActualMatchingContext.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/multiplatform/ClassicExpectActualMatchingContext.kt index 87b146b7815..695e7aff7b8 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/multiplatform/ClassicExpectActualMatchingContext.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/multiplatform/ClassicExpectActualMatchingContext.kt @@ -356,15 +356,15 @@ class ClassicExpectActualMatchingContext( get() = asDescriptor().annotations.map(::AnnotationCallInfoImpl) override fun areAnnotationArgumentsEqual( - annotation1: AnnotationCallInfo, - annotation2: AnnotationCallInfo, + expectAnnotation: AnnotationCallInfo, + actualAnnotation: AnnotationCallInfo, collectionArgumentsCompatibilityCheckStrategy: ExpectActualCollectionArgumentsCompatibilityCheckStrategy, ): Boolean { fun AnnotationCallInfo.getDescriptor(): AnnotationDescriptor = (this as AnnotationCallInfoImpl).annotationDescriptor return areExpressionConstValuesEqual( - annotation1.getDescriptor(), - annotation2.getDescriptor(), + expectAnnotation.getDescriptor(), + actualAnnotation.getDescriptor(), collectionArgumentsCompatibilityCheckStrategy, ) } diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/multiplatform/constExpressionValuesEqualityChecker.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/multiplatform/constExpressionValuesEqualityChecker.kt index 4c9e6c771f8..60c5ef1e1da 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/multiplatform/constExpressionValuesEqualityChecker.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/multiplatform/constExpressionValuesEqualityChecker.kt @@ -11,31 +11,31 @@ import org.jetbrains.kotlin.resolve.calls.mpp.ExpectActualMatchingContext import org.jetbrains.kotlin.resolve.constants.ConstantValue internal fun ExpectActualMatchingContext<*>.areExpressionConstValuesEqual( - a: Any?, - b: Any?, + expectValue: Any?, + actualValue: Any?, collectionArgumentsCompatibilityCheckStrategy: ExpectActualCollectionArgumentsCompatibilityCheckStrategy, ): Boolean { return when { - a is AnnotationDescriptor && b is AnnotationDescriptor -> { - val aArgs = a.allValueArguments - val bArgs = b.allValueArguments + expectValue is AnnotationDescriptor && actualValue is AnnotationDescriptor -> { + val aArgs = expectValue.allValueArguments + val bArgs = actualValue.allValueArguments aArgs.size == bArgs.size && - areCompatibleExpectActualTypes(a.type, b.type) && + areCompatibleExpectActualTypes(expectValue.type, actualValue.type) && aArgs.keys.all { k -> areExpressionConstValuesEqual(aArgs[k], bArgs[k], collectionArgumentsCompatibilityCheckStrategy) } } - a is ConstantValue<*> && b is ConstantValue<*> -> { - areExpressionConstValuesEqual(a.value, b.value, collectionArgumentsCompatibilityCheckStrategy) + expectValue is ConstantValue<*> && actualValue is ConstantValue<*> -> { + areExpressionConstValuesEqual(expectValue.value, actualValue.value, collectionArgumentsCompatibilityCheckStrategy) } - a is Collection<*> && b is Collection<*> -> { - collectionArgumentsCompatibilityCheckStrategy.areCompatible(a, b) { f, s -> + expectValue is Collection<*> && actualValue is Collection<*> -> { + collectionArgumentsCompatibilityCheckStrategy.areCompatible(expectValue, actualValue) { f, s -> areExpressionConstValuesEqual(f, s, collectionArgumentsCompatibilityCheckStrategy) } } - a is Array<*> && b is Array<*> -> { - collectionArgumentsCompatibilityCheckStrategy.areCompatible(a.toList(), b.toList()) { f, s -> + expectValue is Array<*> && actualValue is Array<*> -> { + collectionArgumentsCompatibilityCheckStrategy.areCompatible(expectValue.toList(), actualValue.toList()) { f, s -> areExpressionConstValuesEqual(f, s, collectionArgumentsCompatibilityCheckStrategy) } } - else -> a == b + else -> expectValue == actualValue } } \ No newline at end of file