Files
kotlin-fork/compiler/testData/codegen/box/operatorConventions/augmentedAssignmentInInitializer.kt
T
Nikita Bobko ac40010501 [FE] Prohibit open val deferred initialization
^KT-57553 Fixed
Review: https://jetbrains.team/p/kt/reviews/9967

Other related tests:
- testUninitializedOrReassignedVariables
- testUseOfPropertiesWithoutPrimary
- @TestMetadata("compiler/testData/diagnostics/tests/secondaryConstructors")
- testAugmentedAssignmentInInitializer
- testInitOpenSetter
- testInitOverrideInConstructorComplex
- testPropertyInitializationOrder
2023-05-23 14:12:28 +03:00

46 lines
712 B
Kotlin
Vendored

// !LANGUAGE: -ProhibitOpenValDeferredInitialization
abstract class A {
val b = B("O")
open val c: B
val d: B
get() = field
var e: String
get() = field
init {
c = B("O")
d = B("O")
e = "O"
b += ","
c += "."
d += ";"
e += "|"
}
}
class B(var value: String) {
operator fun plusAssign(o: String) {
value += o
}
}
class C : A() {
init {
b += "K"
c += "K"
d += "K"
e += "K"
}
}
fun box(): String {
val c = C()
val result = "${c.b.value} ${c.c.value} ${c.d.value} ${c.e}"
if (result != "O,K O.K O;K O|K") return "fail: $result"
return "OK"
}