Is the contract ``` contract { callsIn...
# getting-started
f
Is the contract
Copy code
contract {
            callsInPlace(block, InvocationKind.EXACTLY_ONCE)
        }
Valid for a function which may throw before the invocation occurs? That is what if the invocation is guaranteed to occur if no exception is thrown beforehand? Such as:
Copy code
inline fun example(block: ()->Unit) {
    contract {
        callsInPlace(block, InvocationKind.EXACTLY_ONCE)
    }
    doSomeStuffThatMayThrow()
    block()
}
l
Yes. The contract means that if the function
example
completes, then
block
has been executed completely.
1
y
I believe so. That contract is mainly for inferring things that happen afterwards. Also, if the block calls any functions, those could possibly throw as well, and so I don't think the compiler would expect the block to complete fully successfully anyways. Note btw that if your function catches an exception thrown by
block
and doesn't rethrow it, then you should use
AT_MOST_ONCE