Files
kotlin-fork/compiler/testData/diagnostics/tests/inference/builderInference/considerContractsOfIncompleteCalls.kt
T
Denis.Zharkov 7e4d9d9f64 K2: Add new tests for PCLA implementation
Many of them have been found & minimized at FP tests/user projects

^KT-59791 Fixed
2024-01-10 14:56:31 +00:00

25 lines
546 B
Kotlin
Vendored

// WITH_STDLIB
import kotlin.contracts.ExperimentalContracts
import kotlin.contracts.contract
class Controller<T> {
fun yield(t: T): Boolean = true
}
@OptIn(ExperimentalContracts::class)
fun <R, B : Any> Controller<R>.ensureNotNull(value: B?, shift: () -> R): B {
contract { returns() implies (value != null) }
return value!!
}
fun <S> generate(g: suspend Controller<S>.() -> Unit): S = TODO()
fun bar(x: Int) {}
fun foo(x: Int?) {
generate {
ensureNotNull(x) { "" }
bar(<!DEBUG_INFO_SMARTCAST!>x<!>)
}
}