Check whether the field is indeed being initialized
in checkFieldInExactlyOnceLambdaInitialization #KT-40691 Fixed
This commit is contained in:
@@ -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"
|
||||
}
|
||||
Reference in New Issue
Block a user