新版本的变更 / Kotlin 1.6

sealed interface Answer
object Yes : Answer
object No : Answer
object Later : Answer

// *** before: ***
fun old(a: Answer) {
    when (a) {          // a statement was not checked at all:
        Yes -> println("yes")
        No -> println("no")
    }                   // the forgotten Later branch stayed silent
}

// *** in version 1.6: ***
fun new(a: Answer) {
    when (a) {          // a missing branch is a warning since 1.6
        Yes -> println("yes")
        No -> println("no")
        Later -> println("later")
    }                   // and an error since 1.7
}

// the subject types that are checked: sealed classes and interfaces,
// enums and Boolean
fun flag(b: Boolean) {
    when (b) {
        true -> println("on")
        false -> println("off")
    }
}