Check whether the field is indeed being initialized

in checkFieldInExactlyOnceLambdaInitialization
 #KT-40691 Fixed
This commit is contained in:
Ilmir Usmanov
2020-07-30 14:13:51 +02:00
parent d8b76f5b26
commit 2c205410fa
12 changed files with 242 additions and 2 deletions
@@ -0,0 +1,28 @@
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
// IGNORE_BACKEND: NATIVE
// WITH_RUNTIME
// KJS_WITH_FULL_RUNTIME
import kotlin.contracts.*
class A {
val value = "Some value"
init {
foo {
println(value)
}
}
}
fun foo(block: () -> Unit) {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
block()
}
fun box(): String {
A()
return "OK"
}