sealed class Whatever { class Foo : Whatever() class Bar : Whatever() } fun main() { val whatever: Whatever = Whatever.Bar() when (whatever) { is Whatever.Foo -> println("Foo!") } if (whatever is Whatever.Bar) { println("Bar!") } }