b2041e0927
There are many complications with the current design of passing data from within in-place lambdas to surrounding code. Solving these complications will involve more time to investigation than is available within the K2 release. So we are disabling passing type statement information from lambdas for the time being until more time can be devoted to a more complete solution. ^KT-60958 Fixed ^KT-63530 Fixed
68 lines
1.2 KiB
Kotlin
Vendored
68 lines
1.2 KiB
Kotlin
Vendored
// !DUMP_CFG
|
|
// !OPT_IN: kotlin.contracts.ExperimentalContracts
|
|
|
|
import kotlin.contracts.*
|
|
|
|
fun unknown(x: () -> Unit) {
|
|
contract { callsInPlace(x, InvocationKind.UNKNOWN) }
|
|
x()
|
|
}
|
|
|
|
fun atLeastOnce(x: () -> Unit) {
|
|
contract { callsInPlace(x, InvocationKind.AT_LEAST_ONCE) }
|
|
x()
|
|
}
|
|
|
|
fun exactlyOnce(x: () -> Unit) {
|
|
contract { callsInPlace(x, InvocationKind.EXACTLY_ONCE) }
|
|
x()
|
|
}
|
|
|
|
fun atMostOnce(x: () -> Unit) {
|
|
contract { callsInPlace(x, InvocationKind.AT_MOST_ONCE) }
|
|
}
|
|
|
|
fun test1() {
|
|
var x: Any?
|
|
x = ""
|
|
x.length
|
|
unknown { x = 1 }
|
|
x.<!UNRESOLVED_REFERENCE!>length<!>
|
|
x.<!UNRESOLVED_REFERENCE!>inc<!>()
|
|
}
|
|
|
|
fun test1m() {
|
|
var x: Any?
|
|
x = ""
|
|
x.length
|
|
unknown { x = "" }
|
|
x.<!UNRESOLVED_REFERENCE!>length<!>
|
|
}
|
|
|
|
fun test2() {
|
|
var x: Any?
|
|
x = ""
|
|
x.length
|
|
atLeastOnce { x = 1 }
|
|
x.<!UNRESOLVED_REFERENCE!>length<!>
|
|
x.<!UNRESOLVED_REFERENCE!>inc<!>()
|
|
}
|
|
|
|
fun test3() {
|
|
var x: Any?
|
|
x = ""
|
|
x.length
|
|
exactlyOnce { x = 1 }
|
|
x.<!UNRESOLVED_REFERENCE!>length<!>
|
|
x.<!UNRESOLVED_REFERENCE!>inc<!>()
|
|
}
|
|
|
|
fun test4() {
|
|
var x: Any?
|
|
x = ""
|
|
x.length
|
|
atMostOnce { x = 1 }
|
|
x.<!UNRESOLVED_REFERENCE!>length<!>
|
|
x.<!UNRESOLVED_REFERENCE!>inc<!>()
|
|
}
|