Is your feature request related to a problem? Please describe.
Add sealed keyword` to generated interfaces and unions in order to enable exhaustive type-checking in written code. For example
sealed interface Animal {}
data class Cat(val foo: String): Animal
data class Dog(val bar: String): Animal
fun cases(obj: Animal) {
return when (obj) {
is Cat -> "foo"
is Dog -> "bar"; // Removing this line will fail compilation
}
}
The Kotlin language will default to exhaustive when statements (expressions are already exhaustive) in version 1.7, which will make it easier to take advantage of this feature. https://kotlinlang.org/docs/whatsnew1530.html#exhaustive-when-statements-for-sealed-and-boolean-subjects
Describe the solution you'd like
A generateSealedInterfaces build parameter that if true will add the sealed keyword to generated interfaces in Kotlin
Describe alternatives you've considered
n/a
Is your feature request related to a problem? Please describe.
Add
sealedkeyword` to generated interfaces and unions in order to enable exhaustive type-checking in written code. For exampleThe Kotlin language will default to exhaustive
whenstatements (expressions are already exhaustive) in version 1.7, which will make it easier to take advantage of this feature. https://kotlinlang.org/docs/whatsnew1530.html#exhaustive-when-statements-for-sealed-and-boolean-subjectsDescribe the solution you'd like
A
generateSealedInterfacesbuild parameter that if true will add thesealedkeyword to generated interfaces in KotlinDescribe alternatives you've considered
n/a