On a different note, would it ever be possible to ...
# language-proposals
a
On a different note, would it ever be possible to have code like this (two values for simplicity) compile:
Copy code
enum class Bit {
    ZERO, ONE
}

fun test(bit: Bit): Int {
    if (bit == Bit.ZERO) {
        return 0
    }
    return when (bit) {
        Bit.ONE -> 1
    }
}
meaning exhaustive
when
, where some branches have been exhausted before the
when
? Would that be something useful?
a
Is there a use case for this when you can use one
when
and add all the logic within each case?
k
In general I would love it if the exhaustiveness checker would be a bit smarter, it should know that
bit == Bit.ONE
for all code after the
if
IMO.
Of course that's easier said than done 😄
r
How about compilation time, checker can be smarter, be it also must run more time, do you agree to wait?