KT-14210 for loop to stdlib: max/min is not recognized if there is additional if
#KT-14210 Fixed
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filter{}.max()'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.max()'"
|
||||
fun f(list: List<Int>) {
|
||||
var result = -1
|
||||
<caret>for (item in list)
|
||||
if (item % 2 == 0)
|
||||
if (result <= item)
|
||||
result = item
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filter{}.max()'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.max()'"
|
||||
fun f(list: List<Int>) {
|
||||
val <caret>result = list
|
||||
.filter { it % 2 == 0 }
|
||||
.max()
|
||||
?: -1
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filter{}.max()'"
|
||||
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.max()'"
|
||||
fun f(list: List<Int>) {
|
||||
val <caret>result = list
|
||||
.asSequence()
|
||||
.filter { it % 2 == 0 }
|
||||
.max()
|
||||
?: -1
|
||||
}
|
||||
Reference in New Issue
Block a user