7e4d9d9f64
Many of them have been found & minimized at FP tests/user projects ^KT-59791 Fixed
25 lines
546 B
Kotlin
Vendored
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<!>)
|
|
}
|
|
}
|