I have an interface for a value which is always computed, so I don’t need a backing field. (I replaced the computed object with a string in the example.)
When I write it like this:
interface MyInter {
val x: String
}
class Test : MyInter {
override val x = "";
}
AndroidStudio/IDEA tells me that x has backing field, so I write:
class Test {
override val x get() = "";
}
which works, but now Kotlin wants me to add a type-annotation.
Is there a specific reason for this and a way around it? I search the bugtracker, but couldn’t find anything.
I have many nested interfaces in my application, so many override s. It would be cool if I could just write:
interface Outer {
val inner: Inner;
}
interface Inner {
val x: String;
}
class Test : Outer {
override val inner = object {
override val x = "something"
}
}