Initializer is now required for mutable properties with backing fields and open or custom setter #KT-9449 Fixed

Setters without body are not taken into account accordingly to KT-9449.
Old INITIALIZATION_USING_BACKING_FIELD_SETTER are both dropped.
This commit is contained in:
Mikhail Glukhikh
2015-10-14 15:25:25 +03:00
parent 9c9ab671b3
commit c0faf82f77
9 changed files with 112 additions and 26 deletions
@@ -0,0 +1,27 @@
abstract class My(val v: Int) {
// Ok: variable is just abstract
abstract var x: Int
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>open var y: Int<!>
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>open var z: Int<!>
// Ok: initializer available
open var w: Int = v
set(arg) { field = arg }
// Ok: no backing field, no initializer possible
open var u: Int
get() = w
set(arg) { w = 2 * arg }
constructor(): this(0) {
z = v
}
init {
x = 1
y = 2
u = 3
}
}