FIR CFG: process called-in-place lambdas as loops

This commit is contained in:
pyos
2022-06-16 12:58:55 +02:00
committed by Dmitriy Novozhilov
parent 8214e4f806
commit 06c7572ee5
16 changed files with 116 additions and 31 deletions
@@ -0,0 +1,12 @@
// See also KT-7186 and varCapturedInInlineClosure.kt
// Standard library `forEach` calls lambda in-place by contract so smart cast is safe
fun indexOfMax(a: IntArray): Int? {
var maxI: Int? = null
a.forEachIndexed { i, value ->
if (maxI == null || value >= a[maxI]) {
maxI = i
}
}
return maxI
}
@@ -1,5 +1,5 @@
// FIR_IDENTICAL
// KT-7186: False "Type mismatch" error
// See also KT-7186 and varCapturedInInlineClosure.kt
// Standard library `forEach` calls lambda in-place by contract so smart cast is safe
fun indexOfMax(a: IntArray): Int? {
var maxI: Int? = null