Kotlin sealed class inheritance [Incompatible types, Type mismatch]
I have declared a sealed class BaseEvent that contains a data class Event1 and sealed class EventImpl that inherits from BaseEvent and defines its own data class Event2. I want to check the parameter with the exhaustive when expression.
Error:
Incompatible types: BaseEvent.Event1 and EventImpl
Type mismatch: inferred type is BaseEvent.Event1 but EventImpl was expected
Code:
sealed class BaseEvent {
data class Event1(val value: String) : BaseEvent()
}
sealed class EventImpl : BaseEvent()...