Fix incorrect replacement with 'any' instead of 'all'

#KT-17730 Fixed
This commit is contained in:
Dmitry Jemerov
2017-12-14 17:24:11 +01:00
parent ba4cf4dcc6
commit b775b901cc
11 changed files with 76 additions and 17 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
// WITH_RUNTIME
// INTENTION_TEXT: "Replace with 'any{}'"
// INTENTION_TEXT: "Replace with 'all{}'"
// IS_APPLICABLE_2: false
fun foo(): Boolean {
val foo = listOf(true, true)
@@ -1,7 +1,7 @@
// WITH_RUNTIME
// INTENTION_TEXT: "Replace with 'any{}'"
// INTENTION_TEXT: "Replace with 'all{}'"
// IS_APPLICABLE_2: false
fun foo(): Boolean {
val foo = listOf(true, true)
return foo.any { it }
return foo.all { it }
}
+1 -1
View File
@@ -1,5 +1,5 @@
// WITH_RUNTIME
// INTENTION_TEXT: "Replace with 'any{}'"
// INTENTION_TEXT: "Replace with 'all{}'"
// IS_APPLICABLE_2: false
fun foo(): Boolean {
val foo = listOf(true, true)
@@ -1,9 +1,9 @@
// WITH_RUNTIME
// INTENTION_TEXT: "Replace with 'any{}'"
// INTENTION_TEXT: "Replace with 'all{}'"
// IS_APPLICABLE_2: false
fun foo(): Boolean {
val foo = listOf(true, true)
return foo.any { f1(it) && f2(it) }
return foo.all { f1(it) && f2(it) }
}
fun f1(b: Boolean): Boolean = TODO()
+12
View File
@@ -0,0 +1,12 @@
// WITH_RUNTIME
// INTENTION_TEXT: "Replace with 'all{}'"
// IS_APPLICABLE_2: false
fun foo(): Boolean {
val list = listOf(1, 2, 3, 4, 5)
<caret>for (e in list) {
if (!(e <= 3)) {
return false
}
}
return true
}
@@ -0,0 +1,7 @@
// WITH_RUNTIME
// INTENTION_TEXT: "Replace with 'all{}'"
// IS_APPLICABLE_2: false
fun foo(): Boolean {
val list = listOf(1, 2, 3, 4, 5)
return list.all { it <= 3 }
}
@@ -0,0 +1,12 @@
// WITH_RUNTIME
// INTENTION_TEXT: "Replace with 'any{}'"
// IS_APPLICABLE_2: false
fun foo(): Boolean {
val list = listOf(1, 2, 3, 4, 5)
<caret>for (e in list) {
if (!(e <= 3)) {
return true
}
}
return false
}
@@ -0,0 +1,7 @@
// WITH_RUNTIME
// INTENTION_TEXT: "Replace with 'any{}'"
// IS_APPLICABLE_2: false
fun foo(): Boolean {
val list = listOf(1, 2, 3, 4, 5)
return list.any { !(it <= 3) }
}