case

inline fun case(block: () -> Unit): WhenAsExpressionHelper

In Kotlin, the cases of a when <is <type>>... must be exhaustive only when when is used as an expression. Wrapping each of the cases in this is an attempt to allow when to be easily used as an expression even when an expression isn't actually needed. Example:

when(instance) {
is FooNode -> case { ... }
is BarNode -> case { ... }
}.toUnit()

case returns the sentinel instance of WhenAsExpressionHelper. When used in all cases of a whenand the value is consumed (using the .toUnit() function, the compiler will enforce that the cases of the when are exhaustive.