Files
kotlin-fork/compiler/testData/codegen/boxInline/anonymousObject/kt52795_2.kt
T
Svyatoslav Kuzmich 26c1098a4f [Wasm] Fix inliner issues (KT-56584)
* Fix objects in inline functions and lambdas:
  * Add common lowerings used in K/JS and K/Native
* Fix inline lambda call detection logic in presence of additional casts


Merge-request: KT-MR-8791
Merged-by: Svyatoslav Kuzmich <svyatoslav.kuzmich@jetbrains.com>
2023-02-13 13:14:43 +00:00

35 lines
872 B
Kotlin
Vendored

// NO_CHECK_LAMBDA_INLINING
// IGNORE_BACKEND: JVM
// IGNORE_BACKEND_MULTI_MODULE: JVM, JVM_MULTI_MODULE_OLD_AGAINST_IR
import kotlin.IllegalStateException
// FILE: 1.kt
inline fun <T> mrun(block: () -> T) = block()
inline fun <T> mrunTwice(block: () -> T) : T {
val first = block()
val second = block()
if (first!!::class != second!!::class)
throw IllegalStateException("${first!!::class} != ${second!!::class}")
return first
}
// FILE: 2.kt
fun bar(o: String): String {
val callable = mrun {
fun localAnonymousFun(k: String): String {
fun localAnonymousFunLevel2() = mrunTwice {
object {
fun foo() = o + k
}
}
return localAnonymousFunLevel2().foo()
}
::localAnonymousFun
}
return callable("K")
}
fun box() = bar("O")