ReplaceJavaStaticMethodWithKotlinAnalogInspection: fix false positive for 'Arrays.copyOf'
#KT-32477
This commit is contained in:
+3
-1
@@ -168,7 +168,9 @@ class ReplaceJavaStaticMethodWithKotlinAnalogInspection : AbstractKotlinInspecti
|
||||
)
|
||||
|
||||
private val JAVA_COLLECTIONS = listOf(
|
||||
Replacement("java.util.Arrays.copyOf", "kotlin.collections.copyOf", toExtensionFunction = true),
|
||||
Replacement("java.util.Arrays.copyOf", "kotlin.collections.copyOf", toExtensionFunction = true) {
|
||||
it.valueArguments.size == 2
|
||||
},
|
||||
Replacement("java.util.Arrays.asList", "kotlin.collections.listOf"),
|
||||
Replacement("java.util.Arrays.asList", "kotlin.collections.mutableListOf"),
|
||||
Replacement("java.util.Set.of", "kotlin.collections.setOf"),
|
||||
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
// PROBLEM: none
|
||||
import java.util.Arrays
|
||||
|
||||
fun test() {
|
||||
val array = arrayOf(1, 2, 3)
|
||||
val result = Arrays.<caret>copyOf(array, 3, Array<Double>::class.java)
|
||||
}
|
||||
+5
@@ -9081,6 +9081,11 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
|
||||
runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/collections/nonArraysCopyOf.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("notCopyOf.kt")
|
||||
public void testNotCopyOf() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/collections/notCopyOf.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("qualified.kt")
|
||||
public void testQualified() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/collections/qualified.kt");
|
||||
|
||||
Reference in New Issue
Block a user