Sealed Interfaces in Kotlin
Limitations on where to write the subclasses of a sealed class are a matter of compiler awareness. It needs to know about all the subclasses available in order to ensure exhaustiveness.
tarting on Kotlin 1.5 location restrictions will get relaxed, so we can declare them on different files under the same module. This restricts it to only implementations that “you own”. The Kotlin compiler can still ensure exhaustiveness given that the module is compiled together. This is also possible for sealed classes and sealed interfaces in Java 15.