Will contracts be applied recursively?


Really nice work with the contracts API :slight_smile: Are there plans for the contracts to applied recursively to callee functions as well? For example, in the following (dummy) example, will the createOnce2() function also require to have the same contract, or are there plans for the contracts to be applied recursively from createOnce() to createOnce2()?

fun createOnce(runFunction: ()-> Unit) {
    contract {
        callsInPlace(runFunction, kotlin.contracts.InvocationKind.EXACTLY_ONCE)
fun createOnce2(runFunction: ()-> Unit) {


It will not have the same contract. You may or may not want to change the implementation of createOnce2 later, and if the contract would be automatically generated/copied, that would prevent you from doing so.


Yes, it is an intentional decision to not let contracts apply recursively.