KT-13482 "Loop can be replaced with stdlib operations" changes semantics

#KT-13482 Fixed
This commit is contained in:
Valentin Kipyatkov
2016-08-17 18:06:34 +03:00
parent 38edb58e60
commit 26cdd0d5d5
5 changed files with 47 additions and 3 deletions
@@ -0,0 +1,14 @@
// WITH_RUNTIME
// IS_APPLICABLE: false
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.forEach{}'"
fun getMaxLineWidth(lineCount: Int): Float {
var max_width = 0.0f
<caret>for (i in 0..lineCount - 1) {
if (getLineWidth(i) > max_width) {
max_width = getLineWidth(i)
}
}
return max_width
}
fun getLineWidth(i: Int): Float = TODO()
@@ -0,0 +1,13 @@
// WITH_RUNTIME
// IS_APPLICABLE: false
// INTENTION_TEXT_2: "Replace with 'asSequence().filter{}.forEach{}'"
fun getMaxLineWidth(lineCount: Int): Float {
var max_width = 0.0f
<caret>(0..lineCount - 1)
.asSequence()
.filter { getLineWidth(it) > max_width }
.forEach { max_width = getLineWidth(it) }
return max_width
}
fun getLineWidth(i: Int): Float = TODO()