KT-14341 for to stdlib to forEach: if the loop variable is not used in the last/innerest statement the conversion is not proposed
#KT-14341 Fixed
This commit is contained in:
+2
-2
@@ -1,6 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
// IS_APPLICABLE_2: false
|
||||
// INTENTION_TEXT: "Replace with 'filter{}.forEach{}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.forEach{}'"
|
||||
fun foo(list: List<String>): Long {
|
||||
var count = 0L
|
||||
<caret>for (s in list) {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filter{}.forEach{}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.forEach{}'"
|
||||
fun foo(list: List<String>): Long {
|
||||
var count = 0L
|
||||
list
|
||||
.filter { it.length > 10 }
|
||||
.forEach { count++ }
|
||||
return count
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filter{}.forEach{}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.forEach{}'"
|
||||
fun foo(list: List<String>): Long {
|
||||
var count = 0L
|
||||
list
|
||||
.asSequence()
|
||||
.filter { it.length > 10 }
|
||||
.forEach { count++ }
|
||||
return count
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
// IS_APPLICABLE_2: false
|
||||
// INTENTION_TEXT: "Replace with 'filter{}.forEach{}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.forEach{}'"
|
||||
fun foo(list: List<String>): Int {
|
||||
var count = 0
|
||||
<caret>for (s in list) {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filter{}.forEach{}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.forEach{}'"
|
||||
fun foo(list: List<String>): Int {
|
||||
var count = 0
|
||||
list
|
||||
.filter { it.length > count }
|
||||
.forEach { count++ }
|
||||
return count
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filter{}.forEach{}'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.forEach{}'"
|
||||
fun foo(list: List<String>): Int {
|
||||
var count = 0
|
||||
list
|
||||
.asSequence()
|
||||
.filter { it.length > count }
|
||||
.forEach { count++ }
|
||||
return count
|
||||
}
|
||||
Reference in New Issue
Block a user