here is another possible use-case for union types that is currently not possible:
return when(union) {
is A,
is B -> when(union) {
// smart-cast `union` to A|B union type
// do something common for A & B
when(union) {
is A -> // do A-specific
is B -> // do B-specific
// don't handle `is C`
}
}
is C -> // do C-specific
}