31 lines
527 B
Kotlin
Vendored
31 lines
527 B
Kotlin
Vendored
// IGNORE_BACKEND: JVM
|
|
// IGNORE_BACKEND_MULTI_MODULE: JVM, JVM_IR
|
|
|
|
// FILE: 1.kt
|
|
|
|
package test
|
|
|
|
interface Foo {
|
|
fun compute(): Int
|
|
}
|
|
|
|
inline fun foo(x: Int, block: (Int) -> Foo) = block(x)
|
|
|
|
// FILE: 2.kt
|
|
|
|
import test.*
|
|
|
|
fun bar(): Int {
|
|
return foo(21) { x ->
|
|
val o = object : Foo {
|
|
override fun compute(): Int {
|
|
return call { x * 2 }
|
|
}
|
|
|
|
private fun call(f: () -> Int) = f()
|
|
}
|
|
o
|
|
}.compute()
|
|
}
|
|
|
|
fun box() = if (bar() == 42) "OK" else "fail" |