Files
kotlin-fork/compiler/testData/diagnostics/testsWithStdLib/smartcasts/forEachSafe.kt
T
2021-05-28 15:36:23 +03:00

12 lines
268 B
Kotlin
Vendored

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