Added multi-module test on inline functions

This commit is contained in:
Igor Chevdar
2019-12-17 17:14:46 +03:00
parent bd805d71b1
commit cca3f13e48
10 changed files with 183 additions and 1 deletions
@@ -0,0 +1,26 @@
// IGNORE_BACKEND_FIR: JVM_IR
// IGNORE_BACKEND: NATIVE
// MODULE: lib
// FILE: lib.kt
inline fun <T> T.andAlso(block: (T) -> Unit): T {
block(this)
return this
}
inline fun <T> tryCatch(block: () -> T, onSuccess: (T) -> Unit) {
try {
block()
} catch (e: Throwable) {
return
}.andAlso { onSuccess(it) }
}
// MODULE: main(lib)
// FILE: main.kt
fun box(): String {
var result = false
tryCatch(block = { true }) {
result = it
}
return if (result) "OK" else "Fail"
}