Files
kotlin-fork/compiler/testData/diagnostics/testsWithStdLib/smartcasts/forEachSafe.kt
T
2019-02-01 11:40:20 +03:00

12 lines
315 B
Kotlin
Vendored

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