[kotlin] Java methods should be replaced with Kotlin analog: don't report for Arrays.equals when the parameter isn't two

#KTIJ-19298 Fixed

closes https://github.com/JetBrains/intellij-community/pull/1689

GitOrigin-RevId: a24f0daf11e485e5f7d66bf287fb77c357260fda
This commit is contained in:
Toshiaki Kameyama
2021-09-23 18:08:25 +00:00
committed by intellij-monorepo-bot
parent c9632a3978
commit 4e5a8e2736
3 changed files with 17 additions and 1 deletions
@@ -156,7 +156,9 @@ class ReplaceJavaStaticMethodWithKotlinAnalogInspection : AbstractKotlinInspecti
it.valueArguments.size == 2
},
Replacement("java.util.Arrays.copyOfRange", "kotlin.collections.copyOfRange", ToExtensionFunctionWithNonNullableReceiver),
Replacement("java.util.Arrays.equals", "kotlin.collections.contentEquals", ToExtensionFunctionWithNonNullableArguments),
Replacement("java.util.Arrays.equals", "kotlin.collections.contentEquals", ToExtensionFunctionWithNonNullableArguments) {
it.valueArguments.size == 2
},
Replacement("java.util.Arrays.deepEquals", "kotlin.collections.contentDeepEquals", ToExtensionFunctionWithNonNullableArguments),
Replacement(
"java.util.Arrays.deepHashCode",
@@ -11379,6 +11379,11 @@ public abstract class LocalInspectionTestGenerated extends AbstractLocalInspecti
runTest("testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/collections/equalsWithEOLComment.kt");
}
@TestMetadata("equalsWithIndex.kt")
public void testEqualsWithIndex() throws Exception {
runTest("testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/collections/equalsWithIndex.kt");
}
@TestMetadata("equalsWithNullOther.kt")
public void testEqualsWithNullOther() throws Exception {
runTest("testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/collections/equalsWithNullOther.kt");
@@ -0,0 +1,9 @@
// PROBLEM: none
// RUNTIME_WITH_FULL_JDK
import java.util.Arrays
fun test() {
val a = arrayOf(1, 2, 3)
val b = arrayOf(1, 2, 3)
val result = Arrays.<caret>equals(a, 1, 2, b, 1, 2)
}