Files
kotlin-fork/compiler/testData/codegen/box/inline/kt66017_inlineFromTheSameModule.kt
T
Ivan Kylchik e1180adfbd [Native] Always cast expression to the expected type after inline
Right now, during the process of inlining, the compiler erases types.
Because of that, we can end up with some random type
(for example, `Any`) where the concrete type was
expected (for example, `Int`). Compiler must insert a cast in the
required places.

#KT-66017 Fixed
2024-03-12 08:19:50 +00:00

21 lines
389 B
Kotlin
Vendored

// WITH_STDLIB
inline fun <T> Iterable<T>.myForEach(action: (T) -> Unit): Unit {
for (element in this) action(element)
}
inline fun myRepeat(times: Int, action: (Int) -> Unit) {
for (index in 0 until times) {
action(index)
}
}
fun box(): String {
listOf(1).myForEach { size ->
myRepeat(size) {
return "OK"
}
}
return "Fail"
}