// RUN_PIPELINE_TILL: BACKEND
// ISSUE: KT-64500
import kotlin.contracts.*

fun getCondition(): Boolean = true

@OptIn(ExperimentalContracts::class)
fun test_1(f: () -> Unit) {
    contract { <!WRONG_INVOCATION_KIND!>callsInPlace(f, InvocationKind.AT_LEAST_ONCE)<!> }
    while (true) {
        f()
    }
}

@OptIn(ExperimentalContracts::class)
fun test_2(f: () -> Unit) {
    contract { callsInPlace(f, InvocationKind.AT_LEAST_ONCE) }
    do {
        f()
    } while (true)
}

@OptIn(ExperimentalContracts::class)
fun test_3(f: () -> Unit) {
    contract { <!WRONG_INVOCATION_KIND!>callsInPlace(f, InvocationKind.AT_LEAST_ONCE)<!> }
    while (getCondition()) {
        f()
    }
}

@OptIn(ExperimentalContracts::class)
fun test_4(f: () -> Unit) {
    contract { callsInPlace(f, InvocationKind.AT_LEAST_ONCE) }
    do {
        f()
    } while (getCondition())
}

/* GENERATED_FIR_TAGS: classReference, contractCallsEffect, contracts, doWhileLoop, functionDeclaration, functionalType,
lambdaLiteral, whileLoop */
