mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-17 00:21:28 +00:00
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.
10 lines
141 B
Kotlin
Vendored
10 lines
141 B
Kotlin
Vendored
class A {
|
|
val value: String
|
|
get() = field + "K"
|
|
|
|
constructor(o: String) {
|
|
value = o
|
|
}
|
|
}
|
|
|
|
fun box() = A("O").value |