[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:
committed by
Space Team
parent
77ab13400e
commit
3124cbcbad
+3
-3
@@ -343,14 +343,14 @@ class FirExpectActualMatchingContextImpl private constructor(
|
|||||||
get() = asSymbol().resolvedAnnotationsWithArguments.map(::AnnotationCallInfoImpl)
|
get() = asSymbol().resolvedAnnotationsWithArguments.map(::AnnotationCallInfoImpl)
|
||||||
|
|
||||||
override fun areAnnotationArgumentsEqual(
|
override fun areAnnotationArgumentsEqual(
|
||||||
annotation1: AnnotationCallInfo,
|
expectAnnotation: AnnotationCallInfo,
|
||||||
annotation2: AnnotationCallInfo,
|
actualAnnotation: AnnotationCallInfo,
|
||||||
collectionArgumentsCompatibilityCheckStrategy: ExpectActualCollectionArgumentsCompatibilityCheckStrategy,
|
collectionArgumentsCompatibilityCheckStrategy: ExpectActualCollectionArgumentsCompatibilityCheckStrategy,
|
||||||
): Boolean {
|
): Boolean {
|
||||||
fun AnnotationCallInfo.getFirAnnotation(): FirAnnotation {
|
fun AnnotationCallInfo.getFirAnnotation(): FirAnnotation {
|
||||||
return (this as AnnotationCallInfoImpl).annotation
|
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 {
|
private fun areFirAnnotationsEqual(annotation1: FirAnnotation, annotation2: FirAnnotation): Boolean {
|
||||||
|
|||||||
+3
-3
@@ -472,14 +472,14 @@ internal abstract class IrExpectActualMatchingContext(
|
|||||||
get() = asIr().annotations.map(::AnnotationCallInfoImpl)
|
get() = asIr().annotations.map(::AnnotationCallInfoImpl)
|
||||||
|
|
||||||
override fun areAnnotationArgumentsEqual(
|
override fun areAnnotationArgumentsEqual(
|
||||||
annotation1: AnnotationCallInfo, annotation2: AnnotationCallInfo,
|
expectAnnotation: AnnotationCallInfo, actualAnnotation: AnnotationCallInfo,
|
||||||
collectionArgumentsCompatibilityCheckStrategy: ExpectActualCollectionArgumentsCompatibilityCheckStrategy,
|
collectionArgumentsCompatibilityCheckStrategy: ExpectActualCollectionArgumentsCompatibilityCheckStrategy,
|
||||||
): Boolean {
|
): Boolean {
|
||||||
fun AnnotationCallInfo.getIrElement(): IrConstructorCall = (this as AnnotationCallInfoImpl).irElement
|
fun AnnotationCallInfo.getIrElement(): IrConstructorCall = (this as AnnotationCallInfoImpl).irElement
|
||||||
|
|
||||||
return areIrExpressionConstValuesEqual(
|
return areIrExpressionConstValuesEqual(
|
||||||
annotation1.getIrElement(),
|
expectAnnotation.getIrElement(),
|
||||||
annotation2.getIrElement(),
|
actualAnnotation.getIrElement(),
|
||||||
collectionArgumentsCompatibilityCheckStrategy,
|
collectionArgumentsCompatibilityCheckStrategy,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -177,8 +177,8 @@ interface ExpectActualMatchingContext<T : DeclarationSymbolMarker> : TypeSystemC
|
|||||||
val DeclarationSymbolMarker.annotations: List<AnnotationCallInfo>
|
val DeclarationSymbolMarker.annotations: List<AnnotationCallInfo>
|
||||||
|
|
||||||
fun areAnnotationArgumentsEqual(
|
fun areAnnotationArgumentsEqual(
|
||||||
annotation1: AnnotationCallInfo,
|
expectAnnotation: AnnotationCallInfo,
|
||||||
annotation2: AnnotationCallInfo,
|
actualAnnotation: AnnotationCallInfo,
|
||||||
collectionArgumentsCompatibilityCheckStrategy: ExpectActualCollectionArgumentsCompatibilityCheckStrategy,
|
collectionArgumentsCompatibilityCheckStrategy: ExpectActualCollectionArgumentsCompatibilityCheckStrategy,
|
||||||
): Boolean
|
): Boolean
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -356,15 +356,15 @@ class ClassicExpectActualMatchingContext(
|
|||||||
get() = asDescriptor().annotations.map(::AnnotationCallInfoImpl)
|
get() = asDescriptor().annotations.map(::AnnotationCallInfoImpl)
|
||||||
|
|
||||||
override fun areAnnotationArgumentsEqual(
|
override fun areAnnotationArgumentsEqual(
|
||||||
annotation1: AnnotationCallInfo,
|
expectAnnotation: AnnotationCallInfo,
|
||||||
annotation2: AnnotationCallInfo,
|
actualAnnotation: AnnotationCallInfo,
|
||||||
collectionArgumentsCompatibilityCheckStrategy: ExpectActualCollectionArgumentsCompatibilityCheckStrategy,
|
collectionArgumentsCompatibilityCheckStrategy: ExpectActualCollectionArgumentsCompatibilityCheckStrategy,
|
||||||
): Boolean {
|
): Boolean {
|
||||||
fun AnnotationCallInfo.getDescriptor(): AnnotationDescriptor = (this as AnnotationCallInfoImpl).annotationDescriptor
|
fun AnnotationCallInfo.getDescriptor(): AnnotationDescriptor = (this as AnnotationCallInfoImpl).annotationDescriptor
|
||||||
|
|
||||||
return areExpressionConstValuesEqual(
|
return areExpressionConstValuesEqual(
|
||||||
annotation1.getDescriptor(),
|
expectAnnotation.getDescriptor(),
|
||||||
annotation2.getDescriptor(),
|
actualAnnotation.getDescriptor(),
|
||||||
collectionArgumentsCompatibilityCheckStrategy,
|
collectionArgumentsCompatibilityCheckStrategy,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-13
@@ -11,31 +11,31 @@ import org.jetbrains.kotlin.resolve.calls.mpp.ExpectActualMatchingContext
|
|||||||
import org.jetbrains.kotlin.resolve.constants.ConstantValue
|
import org.jetbrains.kotlin.resolve.constants.ConstantValue
|
||||||
|
|
||||||
internal fun ExpectActualMatchingContext<*>.areExpressionConstValuesEqual(
|
internal fun ExpectActualMatchingContext<*>.areExpressionConstValuesEqual(
|
||||||
a: Any?,
|
expectValue: Any?,
|
||||||
b: Any?,
|
actualValue: Any?,
|
||||||
collectionArgumentsCompatibilityCheckStrategy: ExpectActualCollectionArgumentsCompatibilityCheckStrategy,
|
collectionArgumentsCompatibilityCheckStrategy: ExpectActualCollectionArgumentsCompatibilityCheckStrategy,
|
||||||
): Boolean {
|
): Boolean {
|
||||||
return when {
|
return when {
|
||||||
a is AnnotationDescriptor && b is AnnotationDescriptor -> {
|
expectValue is AnnotationDescriptor && actualValue is AnnotationDescriptor -> {
|
||||||
val aArgs = a.allValueArguments
|
val aArgs = expectValue.allValueArguments
|
||||||
val bArgs = b.allValueArguments
|
val bArgs = actualValue.allValueArguments
|
||||||
aArgs.size == bArgs.size &&
|
aArgs.size == bArgs.size &&
|
||||||
areCompatibleExpectActualTypes(a.type, b.type) &&
|
areCompatibleExpectActualTypes(expectValue.type, actualValue.type) &&
|
||||||
aArgs.keys.all { k -> areExpressionConstValuesEqual(aArgs[k], bArgs[k], collectionArgumentsCompatibilityCheckStrategy) }
|
aArgs.keys.all { k -> areExpressionConstValuesEqual(aArgs[k], bArgs[k], collectionArgumentsCompatibilityCheckStrategy) }
|
||||||
}
|
}
|
||||||
a is ConstantValue<*> && b is ConstantValue<*> -> {
|
expectValue is ConstantValue<*> && actualValue is ConstantValue<*> -> {
|
||||||
areExpressionConstValuesEqual(a.value, b.value, collectionArgumentsCompatibilityCheckStrategy)
|
areExpressionConstValuesEqual(expectValue.value, actualValue.value, collectionArgumentsCompatibilityCheckStrategy)
|
||||||
}
|
}
|
||||||
a is Collection<*> && b is Collection<*> -> {
|
expectValue is Collection<*> && actualValue is Collection<*> -> {
|
||||||
collectionArgumentsCompatibilityCheckStrategy.areCompatible(a, b) { f, s ->
|
collectionArgumentsCompatibilityCheckStrategy.areCompatible(expectValue, actualValue) { f, s ->
|
||||||
areExpressionConstValuesEqual(f, s, collectionArgumentsCompatibilityCheckStrategy)
|
areExpressionConstValuesEqual(f, s, collectionArgumentsCompatibilityCheckStrategy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
a is Array<*> && b is Array<*> -> {
|
expectValue is Array<*> && actualValue is Array<*> -> {
|
||||||
collectionArgumentsCompatibilityCheckStrategy.areCompatible(a.toList(), b.toList()) { f, s ->
|
collectionArgumentsCompatibilityCheckStrategy.areCompatible(expectValue.toList(), actualValue.toList()) { f, s ->
|
||||||
areExpressionConstValuesEqual(f, s, collectionArgumentsCompatibilityCheckStrategy)
|
areExpressionConstValuesEqual(f, s, collectionArgumentsCompatibilityCheckStrategy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else -> a == b
|
else -> expectValue == actualValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user