Hi,
If I define the following two interfaces:
interface Parent {
fun value(): List<String>
}
interface Child : Parent {
override fun value() = throw IllegalStateException()
}
And then try to implement interface Child
:
object ChildImplementation : Child {
override fun value() = listOf("A value")
}
The compiler compains: Return type of ‘value’ is not a subtype of the return type of the overridden member ‘public open fun value(): Nothing defined in …Child’
Is this the expected behavior? I would assume that overriding a function does not allow you to change its return type (except when you change it to a covariant type).