diff --git a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/inspections/jdk2k/ReplaceJavaStaticMethodWithKotlinAnalogInspection.kt b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/inspections/jdk2k/ReplaceJavaStaticMethodWithKotlinAnalogInspection.kt index b6a3a971d368..85a9e38b0e1c 100644 --- a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/inspections/jdk2k/ReplaceJavaStaticMethodWithKotlinAnalogInspection.kt +++ b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/inspections/jdk2k/ReplaceJavaStaticMethodWithKotlinAnalogInspection.kt @@ -158,22 +158,22 @@ 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", ToExtensionFunctionWithNullableReceiver) { it.valueArguments.size == 2 }, - Replacement("java.util.Arrays.deepEquals", "kotlin.collections.contentDeepEquals", ToExtensionFunctionWithNonNullableArguments), + Replacement("java.util.Arrays.deepEquals", "kotlin.collections.contentDeepEquals", ToExtensionFunctionWithNullableReceiver), Replacement( "java.util.Arrays.deepHashCode", "kotlin.collections.contentDeepHashCode", - ToExtensionFunctionWithNonNullableReceiver + ToExtensionFunctionWithNullableReceiver ), - Replacement("java.util.Arrays.hashCode", "kotlin.collections.contentHashCode", ToExtensionFunctionWithNonNullableReceiver), + Replacement("java.util.Arrays.hashCode", "kotlin.collections.contentHashCode", ToExtensionFunctionWithNullableReceiver), Replacement( "java.util.Arrays.deepToString", "kotlin.collections.contentDeepToString", - ToExtensionFunctionWithNonNullableReceiver + ToExtensionFunctionWithNullableReceiver ), - Replacement("java.util.Arrays.toString", "kotlin.collections.contentToString", ToExtensionFunctionWithNonNullableReceiver), + Replacement("java.util.Arrays.toString", "kotlin.collections.contentToString", ToExtensionFunctionWithNullableReceiver), Replacement("java.util.Arrays.asList", "kotlin.collections.listOf"), Replacement("java.util.Arrays.asList", "kotlin.collections.mutableListOf"), Replacement("java.util.Set.of", "kotlin.collections.setOf"), diff --git a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/inspections/jdk2k/Transformation.kt b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/inspections/jdk2k/Transformation.kt index 845b2912a5ee..2d0906c6180d 100644 --- a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/inspections/jdk2k/Transformation.kt +++ b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/inspections/jdk2k/Transformation.kt @@ -68,19 +68,6 @@ object ToExtensionFunctionWithNonNullableReceiver : Transformation { ?.isNullable() == false } -object ToExtensionFunctionWithNonNullableArguments : Transformation { - override fun invoke(callExpression: KtCallExpression, replacement: Replacement) = - ToExtensionFunctionWithNonNullableReceiver(callExpression, replacement) - - override fun isApplicable(callExpression: KtCallExpression): Boolean = - ToExtensionFunctionWithNonNullableReceiver.isApplicable(callExpression) - - override fun isApplicableInContext(callExpression: KtCallExpression, context: BindingContext): Boolean = - callExpression.valueArguments.all { - it.getArgumentExpression()?.getType(context)?.isNullable() == false - } -} - object ToExtensionFunctionWithNullableReceiver : Transformation { override fun invoke(callExpression: KtCallExpression, replacement: Replacement) = ToExtensionFunctionWithNonNullableReceiver(callExpression, replacement) diff --git a/plugins/kotlin/idea/tests/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/collections/deepEqualsWithNullOther.kt b/plugins/kotlin/idea/tests/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/collections/deepEqualsWithNullOther.kt index 66a4efdcd83d..a2a80118d78f 100644 --- a/plugins/kotlin/idea/tests/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/collections/deepEqualsWithNullOther.kt +++ b/plugins/kotlin/idea/tests/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/collections/deepEqualsWithNullOther.kt @@ -1,5 +1,4 @@ // WITH_STDLIB -// PROBLEM: none import java.util.Arrays fun test() { diff --git a/plugins/kotlin/idea/tests/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/collections/deepEqualsWithNullOther.kt.after b/plugins/kotlin/idea/tests/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/collections/deepEqualsWithNullOther.kt.after new file mode 100644 index 000000000000..1bad34fb22b0 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/collections/deepEqualsWithNullOther.kt.after @@ -0,0 +1,8 @@ +// WITH_STDLIB +import java.util.Arrays + +fun test() { + val a = arrayOf(1, 2, 3) + val b: Array<*>? = null + val result = a.contentDeepEquals(b) +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/collections/equalsWithNullOther.kt b/plugins/kotlin/idea/tests/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/collections/equalsWithNullOther.kt index c2b1eeee1b27..4c3e50880040 100644 --- a/plugins/kotlin/idea/tests/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/collections/equalsWithNullOther.kt +++ b/plugins/kotlin/idea/tests/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/collections/equalsWithNullOther.kt @@ -1,5 +1,4 @@ // WITH_STDLIB -// PROBLEM: none import java.util.Arrays fun test() { diff --git a/plugins/kotlin/idea/tests/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/collections/equalsWithNullOther.kt.after b/plugins/kotlin/idea/tests/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/collections/equalsWithNullOther.kt.after new file mode 100644 index 000000000000..bba3129c2841 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/collections/equalsWithNullOther.kt.after @@ -0,0 +1,8 @@ +// WITH_STDLIB +import java.util.Arrays + +fun test() { + val a = arrayOf(1, 2, 3) + val b: Array<*>? = null + val result = a.contentEquals(b) +} \ No newline at end of file diff --git a/plugins/kotlin/idea/tests/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/collections/toStringWithNullableReceiver.kt b/plugins/kotlin/idea/tests/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/collections/toStringWithNullableReceiver.kt index 84da006dc2af..984994592cdb 100644 --- a/plugins/kotlin/idea/tests/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/collections/toStringWithNullableReceiver.kt +++ b/plugins/kotlin/idea/tests/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/collections/toStringWithNullableReceiver.kt @@ -1,5 +1,4 @@ // WITH_STDLIB -// PROBLEM: none import java.util.Arrays fun test() { diff --git a/plugins/kotlin/idea/tests/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/collections/toStringWithNullableReceiver.kt.after b/plugins/kotlin/idea/tests/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/collections/toStringWithNullableReceiver.kt.after new file mode 100644 index 000000000000..e84f6281fb5e --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/inspectionsLocal/replaceJavaStaticMethodWithKotlinAnalog/collections/toStringWithNullableReceiver.kt.after @@ -0,0 +1,7 @@ +// WITH_STDLIB +import java.util.Arrays + +fun test() { + val a: Array<*>? = arrayOf(1) + val str = a.contentToString() +} \ No newline at end of file