[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
This commit is contained in:
Roman Efremov
2023-08-23 09:50:00 +02:00
committed by Space Team
parent 77ab13400e
commit 3124cbcbad
5 changed files with 25 additions and 25 deletions
@@ -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 {
@@ -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,
)
}
@@ -177,8 +177,8 @@ interface ExpectActualMatchingContext<T : DeclarationSymbolMarker> : TypeSystemC
val DeclarationSymbolMarker.annotations: List<AnnotationCallInfo>
fun areAnnotationArgumentsEqual(
annotation1: AnnotationCallInfo,
annotation2: AnnotationCallInfo,
expectAnnotation: AnnotationCallInfo,
actualAnnotation: AnnotationCallInfo,
collectionArgumentsCompatibilityCheckStrategy: ExpectActualCollectionArgumentsCompatibilityCheckStrategy,
): Boolean
@@ -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,
)
}
@@ -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
}
}