Don't generate .forEach { return } when converting loop to call chain
#KT-17161 Fixed
This commit is contained in:
+2
-2
@@ -1,6 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filter{}.forEach{}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.forEach{}'"
|
||||
// IS_APPLICABLE: false
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(list: List<String?>): String? {
|
||||
<caret>for (s in list) {
|
||||
if (s == null || s.isNotEmpty()) {
|
||||
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filter{}.forEach{}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.forEach{}'"
|
||||
fun foo(list: List<String?>): String? {
|
||||
list
|
||||
.filter { it == null || it.isNotEmpty() }
|
||||
.forEach { return it }
|
||||
return ""
|
||||
}
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filter{}.forEach{}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.forEach{}'"
|
||||
fun foo(list: List<String?>): String? {
|
||||
list
|
||||
.asSequence()
|
||||
.filter { it == null || it.isNotEmpty() }
|
||||
.forEach { return it }
|
||||
return ""
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
// IS_APPLICABLE_2: false
|
||||
fun foo(l: List<() -> Boolean>) {
|
||||
<caret>for (i in 0 until l.size) {
|
||||
if (l[i]()) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user