Files
kotlin-fork/compiler/testData/cfgWithStdLib/contracts/tryCatchFinally.kt
T
Dmitry Savvinov f487525a1d Effects: add cfg-tests on inlined lambdas
==========
Introduction of Effect System: 15/18
2017-10-12 11:55:26 +03:00

32 lines
543 B
Kotlin
Vendored

// LANGUAGE_VERSION: 1.3
import kotlin.internal.contracts.*
inline fun <T> myRun(block: () -> T): T {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
return block()
}
fun someComputation(): Int = 42
fun report(x: Int) = Unit
fun innerTryCatchFinally() {
val x: Int
myRun {
try {
x = someComputation()
report(x)
} catch (e: java.lang.Exception) {
x = 42
report(x)
} finally {
x = 0
}
}
x.inc()
}