joscha.alisch
12/21/2017, 11:32 AMval property in a subclass, one can specify a subtype of the original type as return type.
open class A() {
open val property: A? get() = A()
…
Class B : A() {
override val property: B? get() = B()
On a var, specifying the setters type to something below the original is obviously not possible. But I would expect that I could do that for the getter, like so
Class B : A() {
override var property: A?
get(): B? = B()
That fails however with Getter return type must be equal to the type of the property.
Is there any way of achieving this? Does it make sense to file a feature request for allowing subtypes as return type of getters?