Files
kotlin-fork/compiler/testData/diagnostics/testsWithStdLib/smartcasts/forEachUnsafe.fir.kt
T

14 lines
285 B
Kotlin
Vendored

// KT-7186: False "Type mismatch" error
fun indexOfMax(a: IntArray): Int? {
var maxI: Int? = 0
a.forEachIndexed { i, value ->
if (value >= a[maxI]) {
maxI = i
}
else if (value < 0) {
maxI = null
}
}
return maxI
}