contract

Specifies the contract of a function.

@ExperimentalContractsinline fun contract(builder: ContractBuilder.() -> Unit)(source)
import kotlin.contracts.*

@OptIn(ExperimentalContracts::class)
inline fun <T> T?.requireNotNull(): T {
    contract { returnsNotNull() implies (this@requireNotNull != null) }
    return this ?: throw IllegalArgumentException("value must not be null")
}

Source