Ease field initialization check

Since there is already VAL_REASSIGNMENT diagnostics, we can safely only
for direct assignments.
 #KT-40893 Fixed
This commit is contained in:
Ilmir Usmanov
2020-08-06 17:38:54 +02:00
parent 6c0abe7e48
commit b403b63f48
10 changed files with 73 additions and 5 deletions
+28
View File
@@ -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 = arrayListOf("O")
init {
foo {
value += "K"
}
}
}
fun foo(block: () -> Unit) {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
block()
}
fun box(): String {
val a = A()
return if (a.value == listOf("O", "K")) "OK" else "FAIL"
}