diff --git a/idea/testData/inspectionsLocal/liftOut/ifToAssignment/typeMismatch2.kt b/idea/testData/inspectionsLocal/liftOut/ifToAssignment/typeMismatch2.kt index a922662bdb9..6de308e6750 100644 --- a/idea/testData/inspectionsLocal/liftOut/ifToAssignment/typeMismatch2.kt +++ b/idea/testData/inspectionsLocal/liftOut/ifToAssignment/typeMismatch2.kt @@ -1,3 +1,4 @@ +// COMPILER_ARGUMENTS: -XXLanguage:-NewInference // PROBLEM: none // ERROR: Type mismatch: inferred type is Long? but Long was expected fun test(b: Boolean, x: Long, y: Long?) { diff --git a/idea/testData/inspectionsLocal/liftOut/ifToAssignment/typeMismatch2_ni.kt b/idea/testData/inspectionsLocal/liftOut/ifToAssignment/typeMismatch2_ni.kt new file mode 100644 index 00000000000..4d62e6b68e6 --- /dev/null +++ b/idea/testData/inspectionsLocal/liftOut/ifToAssignment/typeMismatch2_ni.kt @@ -0,0 +1,12 @@ +// COMPILER_ARGUMENTS: -XXLanguage:+NewInference +// PROBLEM: Assignment should be lifted out of 'if' +// ERROR: None of the following functions can be called with the arguments supplied:
public final operator fun plus(other: Byte): Long defined in kotlin.Long
public final operator fun plus(other: Double): Double defined in kotlin.Long
public final operator fun plus(other: Float): Float defined in kotlin.Long
public final operator fun plus(other: Int): Long defined in kotlin.Long
public final operator fun plus(other: Long): Long defined in kotlin.Long
public final operator fun plus(other: Short): Long defined in kotlin.Long + +fun test(b: Boolean, x: Long, y: Long?) { + var num: Long = 0L + if (b) { + num += x + } else { + num += y + } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/liftOut/ifToAssignment/typeMismatch2_ni.kt.after b/idea/testData/inspectionsLocal/liftOut/ifToAssignment/typeMismatch2_ni.kt.after new file mode 100644 index 00000000000..b2b1148c823 --- /dev/null +++ b/idea/testData/inspectionsLocal/liftOut/ifToAssignment/typeMismatch2_ni.kt.after @@ -0,0 +1,12 @@ +// COMPILER_ARGUMENTS: -XXLanguage:+NewInference +// PROBLEM: Assignment should be lifted out of 'if' +// ERROR: None of the following functions can be called with the arguments supplied:
public final operator fun plus(other: Byte): Long defined in kotlin.Long
public final operator fun plus(other: Double): Double defined in kotlin.Long
public final operator fun plus(other: Float): Float defined in kotlin.Long
public final operator fun plus(other: Int): Long defined in kotlin.Long
public final operator fun plus(other: Long): Long defined in kotlin.Long
public final operator fun plus(other: Short): Long defined in kotlin.Long + +fun test(b: Boolean, x: Long, y: Long?) { + var num: Long = 0L + num += if (b) { + x + } else { + y + } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/liftOut/ifToAssignment/typeMismatchMutableList2.kt b/idea/testData/inspectionsLocal/liftOut/ifToAssignment/typeMismatchMutableList2.kt index 84feccbfecf..c1b0f8ae061 100644 --- a/idea/testData/inspectionsLocal/liftOut/ifToAssignment/typeMismatchMutableList2.kt +++ b/idea/testData/inspectionsLocal/liftOut/ifToAssignment/typeMismatchMutableList2.kt @@ -1,3 +1,4 @@ +// COMPILER_ARGUMENTS: -XXLanguage:-NewInference // PROBLEM: none // ERROR: Type mismatch: inferred type is List but MutableList was expected // ERROR: Val cannot be reassigned diff --git a/idea/testData/inspectionsLocal/liftOut/ifToAssignment/typeMismatchMutableList2_ni.kt b/idea/testData/inspectionsLocal/liftOut/ifToAssignment/typeMismatchMutableList2_ni.kt new file mode 100644 index 00000000000..e836138da84 --- /dev/null +++ b/idea/testData/inspectionsLocal/liftOut/ifToAssignment/typeMismatchMutableList2_ni.kt @@ -0,0 +1,14 @@ +// COMPILER_ARGUMENTS: -XXLanguage:+NewInference +// PROBLEM: none +// ERROR: Type mismatch: inferred type is List<{Comparable<{Int & Long}> & Number}> but MutableList was expected +// ERROR: Val cannot be reassigned +// WITH_RUNTIME + +fun test(b: Boolean) { + val list = mutableListOf() + if (b) { + list += mutableListOf(1) + } else { + list += mutableListOf(2L) + } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/redundantLambdaArrow/notApplicableVararg.kt b/idea/testData/inspectionsLocal/redundantLambdaArrow/notApplicableVararg.kt index b7330abedd8..416a01f2ece 100644 --- a/idea/testData/inspectionsLocal/redundantLambdaArrow/notApplicableVararg.kt +++ b/idea/testData/inspectionsLocal/redundantLambdaArrow/notApplicableVararg.kt @@ -1,3 +1,4 @@ +// COMPILER_ARGUMENTS: -XXLanguage:-NewInference // PROBLEM: none // WITH_RUNTIME diff --git a/idea/testData/inspectionsLocal/redundantLambdaArrow/notApplicableVararg2.kt b/idea/testData/inspectionsLocal/redundantLambdaArrow/notApplicableVararg2.kt index 40408ac6e59..4d68bac2bc2 100644 --- a/idea/testData/inspectionsLocal/redundantLambdaArrow/notApplicableVararg2.kt +++ b/idea/testData/inspectionsLocal/redundantLambdaArrow/notApplicableVararg2.kt @@ -1,3 +1,4 @@ +// COMPILER_ARGUMENTS: -XXLanguage:-NewInference // PROBLEM: none // WITH_RUNTIME diff --git a/idea/testData/inspectionsLocal/redundantLambdaArrow/notApplicableVararg2_ni.kt b/idea/testData/inspectionsLocal/redundantLambdaArrow/notApplicableVararg2_ni.kt new file mode 100644 index 00000000000..20983e32d8f --- /dev/null +++ b/idea/testData/inspectionsLocal/redundantLambdaArrow/notApplicableVararg2_ni.kt @@ -0,0 +1,14 @@ +// COMPILER_ARGUMENTS: -XXLanguage:+NewInference +// PROBLEM: Redundant lambda arrow +// WITH_RUNTIME + +fun main() { + registerHandler(handlers = *arrayOf( + { _ -> }, + { it -> } + )) +} + +fun registerHandler(vararg handlers: (String) -> Unit) { + handlers.forEach { it.invoke("hello") } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/redundantLambdaArrow/notApplicableVararg2_ni.kt.after b/idea/testData/inspectionsLocal/redundantLambdaArrow/notApplicableVararg2_ni.kt.after new file mode 100644 index 00000000000..bb8918db77c --- /dev/null +++ b/idea/testData/inspectionsLocal/redundantLambdaArrow/notApplicableVararg2_ni.kt.after @@ -0,0 +1,14 @@ +// COMPILER_ARGUMENTS: -XXLanguage:+NewInference +// PROBLEM: Redundant lambda arrow +// WITH_RUNTIME + +fun main() { + registerHandler(handlers = *arrayOf( + { _ -> }, + { } + )) +} + +fun registerHandler(vararg handlers: (String) -> Unit) { + handlers.forEach { it.invoke("hello") } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/redundantLambdaArrow/notApplicableVararg_ni.kt b/idea/testData/inspectionsLocal/redundantLambdaArrow/notApplicableVararg_ni.kt new file mode 100644 index 00000000000..9d0455ef267 --- /dev/null +++ b/idea/testData/inspectionsLocal/redundantLambdaArrow/notApplicableVararg_ni.kt @@ -0,0 +1,14 @@ +// COMPILER_ARGUMENTS: -XXLanguage:+NewInference +// PROBLEM: Redundant lambda arrow +// WITH_RUNTIME + +fun main() { + registerHandler(handlers = *arrayOf( + { _ -> }, + { it -> } + )) +} + +fun registerHandler(vararg handlers: (String) -> Unit) { + handlers.forEach { it.invoke("hello") } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/redundantLambdaArrow/notApplicableVararg_ni.kt.after b/idea/testData/inspectionsLocal/redundantLambdaArrow/notApplicableVararg_ni.kt.after new file mode 100644 index 00000000000..16fd01c2cb4 --- /dev/null +++ b/idea/testData/inspectionsLocal/redundantLambdaArrow/notApplicableVararg_ni.kt.after @@ -0,0 +1,14 @@ +// COMPILER_ARGUMENTS: -XXLanguage:+NewInference +// PROBLEM: Redundant lambda arrow +// WITH_RUNTIME + +fun main() { + registerHandler(handlers = *arrayOf( + { }, + { it -> } + )) +} + +fun registerHandler(vararg handlers: (String) -> Unit) { + handlers.forEach { it.invoke("hello") } +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/redundantLambdaArrow/typeParameter2.kt b/idea/testData/inspectionsLocal/redundantLambdaArrow/typeParameter2.kt index 70bc518e3f0..7ccfe3e6c27 100644 --- a/idea/testData/inspectionsLocal/redundantLambdaArrow/typeParameter2.kt +++ b/idea/testData/inspectionsLocal/redundantLambdaArrow/typeParameter2.kt @@ -1,3 +1,4 @@ +// COMPILER_ARGUMENTS: -XXLanguage:-NewInference // PROBLEM: none class Foo(val t: T) diff --git a/idea/testData/inspectionsLocal/redundantLambdaArrow/typeParameter2_ni.kt b/idea/testData/inspectionsLocal/redundantLambdaArrow/typeParameter2_ni.kt new file mode 100644 index 00000000000..d3fc394da2b --- /dev/null +++ b/idea/testData/inspectionsLocal/redundantLambdaArrow/typeParameter2_ni.kt @@ -0,0 +1,9 @@ +// COMPILER_ARGUMENTS: -XXLanguage:+NewInference +// PROBLEM: Redundant lambda arrow +class Foo(val t: T) + +fun bar(foo: Foo<(Boolean) -> String>) {} + +fun test() { + bar(Foo({ _ -> "" })) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/redundantLambdaArrow/typeParameter2_ni.kt.after b/idea/testData/inspectionsLocal/redundantLambdaArrow/typeParameter2_ni.kt.after new file mode 100644 index 00000000000..adce340e8b5 --- /dev/null +++ b/idea/testData/inspectionsLocal/redundantLambdaArrow/typeParameter2_ni.kt.after @@ -0,0 +1,9 @@ +// COMPILER_ARGUMENTS: -XXLanguage:+NewInference +// PROBLEM: Redundant lambda arrow +class Foo(val t: T) + +fun bar(foo: Foo<(Boolean) -> String>) {} + +fun test() { + bar(Foo({ "" })) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/redundantLambdaArrow/typeParameter3.kt b/idea/testData/inspectionsLocal/redundantLambdaArrow/typeParameter3.kt index 2f8cfcf772e..b81fe105ccc 100644 --- a/idea/testData/inspectionsLocal/redundantLambdaArrow/typeParameter3.kt +++ b/idea/testData/inspectionsLocal/redundantLambdaArrow/typeParameter3.kt @@ -1,3 +1,4 @@ +// COMPILER_ARGUMENTS: -XXLanguage:-NewInference // PROBLEM: none // WITH_RUNTIME diff --git a/idea/testData/inspectionsLocal/redundantLambdaArrow/typeParameter3_ni.kt b/idea/testData/inspectionsLocal/redundantLambdaArrow/typeParameter3_ni.kt new file mode 100644 index 00000000000..643b7cc5532 --- /dev/null +++ b/idea/testData/inspectionsLocal/redundantLambdaArrow/typeParameter3_ni.kt @@ -0,0 +1,11 @@ +// COMPILER_ARGUMENTS: -XXLanguage:+NewInference +// PROBLEM: Redundant lambda arrow +// WITH_RUNTIME + +fun f(cbs: List<(Boolean) -> Unit>) { + cbs[0](true) +} + +fun main() { + f(listOf({ _ -> println("hello") })) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/redundantLambdaArrow/typeParameter3_ni.kt.after b/idea/testData/inspectionsLocal/redundantLambdaArrow/typeParameter3_ni.kt.after new file mode 100644 index 00000000000..65cb06b1c39 --- /dev/null +++ b/idea/testData/inspectionsLocal/redundantLambdaArrow/typeParameter3_ni.kt.after @@ -0,0 +1,11 @@ +// COMPILER_ARGUMENTS: -XXLanguage:+NewInference +// PROBLEM: Redundant lambda arrow +// WITH_RUNTIME + +fun f(cbs: List<(Boolean) -> Unit>) { + cbs[0](true) +} + +fun main() { + f(listOf({ println("hello") })) +} \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/suspiciousCollectionReassignment/hasError.kt b/idea/testData/inspectionsLocal/suspiciousCollectionReassignment/hasError.kt index dc178c211b6..1e238509136 100644 --- a/idea/testData/inspectionsLocal/suspiciousCollectionReassignment/hasError.kt +++ b/idea/testData/inspectionsLocal/suspiciousCollectionReassignment/hasError.kt @@ -1,6 +1,8 @@ // PROBLEM: none // WITH_RUNTIME // ERROR: Type mismatch: inferred type is List but List was expected +// COMPILER_ARGUMENTS: -XXLanguage:-NewInference + fun test() { var list = listOf("") list += 1 diff --git a/idea/testData/inspectionsLocal/suspiciousCollectionReassignment/hasError_ni.kt b/idea/testData/inspectionsLocal/suspiciousCollectionReassignment/hasError_ni.kt new file mode 100644 index 00000000000..de4fe603c9c --- /dev/null +++ b/idea/testData/inspectionsLocal/suspiciousCollectionReassignment/hasError_ni.kt @@ -0,0 +1,9 @@ +// PROBLEM: none +// WITH_RUNTIME +// ERROR: Type mismatch: inferred type is List<{Comparable<{Int & String}> & java.io.Serializable}> but List was expected +// COMPILER_ARGUMENTS: -XXLanguage:+NewInference + +fun test() { + var list = listOf("") + list += 1 +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java index ce06d35dfa1..7f86367ea35 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java @@ -3575,6 +3575,11 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest { runTest("idea/testData/inspectionsLocal/liftOut/ifToAssignment/typeMismatch2.kt"); } + @TestMetadata("typeMismatch2_ni.kt") + public void testTypeMismatch2_ni() throws Exception { + runTest("idea/testData/inspectionsLocal/liftOut/ifToAssignment/typeMismatch2_ni.kt"); + } + @TestMetadata("typeMismatch3.kt") public void testTypeMismatch3() throws Exception { runTest("idea/testData/inspectionsLocal/liftOut/ifToAssignment/typeMismatch3.kt"); @@ -3589,6 +3594,11 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest { public void testTypeMismatchMutableList2() throws Exception { runTest("idea/testData/inspectionsLocal/liftOut/ifToAssignment/typeMismatchMutableList2.kt"); } + + @TestMetadata("typeMismatchMutableList2_ni.kt") + public void testTypeMismatchMutableList2_ni() throws Exception { + runTest("idea/testData/inspectionsLocal/liftOut/ifToAssignment/typeMismatchMutableList2_ni.kt"); + } } @TestMetadata("idea/testData/inspectionsLocal/liftOut/ifToReturn") @@ -5418,6 +5428,16 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest { runTest("idea/testData/inspectionsLocal/redundantLambdaArrow/notApplicableVararg2.kt"); } + @TestMetadata("notApplicableVararg2_ni.kt") + public void testNotApplicableVararg2_ni() throws Exception { + runTest("idea/testData/inspectionsLocal/redundantLambdaArrow/notApplicableVararg2_ni.kt"); + } + + @TestMetadata("notApplicableVararg_ni.kt") + public void testNotApplicableVararg_ni() throws Exception { + runTest("idea/testData/inspectionsLocal/redundantLambdaArrow/notApplicableVararg_ni.kt"); + } + @TestMetadata("overload4.kt") public void testOverload4() throws Exception { runTest("idea/testData/inspectionsLocal/redundantLambdaArrow/overload4.kt"); @@ -5438,11 +5458,21 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest { runTest("idea/testData/inspectionsLocal/redundantLambdaArrow/typeParameter2.kt"); } + @TestMetadata("typeParameter2_ni.kt") + public void testTypeParameter2_ni() throws Exception { + runTest("idea/testData/inspectionsLocal/redundantLambdaArrow/typeParameter2_ni.kt"); + } + @TestMetadata("typeParameter3.kt") public void testTypeParameter3() throws Exception { runTest("idea/testData/inspectionsLocal/redundantLambdaArrow/typeParameter3.kt"); } + @TestMetadata("typeParameter3_ni.kt") + public void testTypeParameter3_ni() throws Exception { + runTest("idea/testData/inspectionsLocal/redundantLambdaArrow/typeParameter3_ni.kt"); + } + @TestMetadata("underscore.kt") public void testUnderscore() throws Exception { runTest("idea/testData/inspectionsLocal/redundantLambdaArrow/underscore.kt"); @@ -8934,6 +8964,11 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest { runTest("idea/testData/inspectionsLocal/suspiciousCollectionReassignment/hasError.kt"); } + @TestMetadata("hasError_ni.kt") + public void testHasError_ni() throws Exception { + runTest("idea/testData/inspectionsLocal/suspiciousCollectionReassignment/hasError_ni.kt"); + } + @TestMetadata("int.kt") public void testInt() throws Exception { runTest("idea/testData/inspectionsLocal/suspiciousCollectionReassignment/int.kt");