Files
kotlin/compiler/testData/codegen/box/secondaryConstructors/withoutPrimarySimple.kt
Anton Bannykh 44d56cb278 JS: fix val with backing field initialization in secondary constructors
This change reverts the AssignmentTranslator logic to a previous state
of "if we assign to a val, tranlate to backing field". Previously a
check whether or not we are inside of a constructor was added. The
check didn't detect secondary constructors, hence initializing of
val's with backing field started to work incorrectly.

The check itself was added in an attempt to prevent augmented assignment
operators to reference the backing field. The check seems to have been
wrong, because an augmented assignment could happen inside a construcotr.
A more correct fix was added later. It seems that it is safe now to
revert the logic back and rely on the frontend to only allow assignment
to a val property during initilization.
2018-10-10 17:25:55 +03:00

10 lines
141 B
Kotlin
Vendored

class A {
val value: String
get() = field + "K"
constructor(o: String) {
value = o
}
}
fun box() = A("O").value