Files
kotlin-fork/compiler/testData/diagnostics/tests/sealed/ExhaustiveWhenNegatedTwice.kt
T
Nikolay Lunyak 88ff93df7f [FIR] Check is for impossibility
^KT-58203 Fixed
^KT-62646
2024-03-08 15:37:44 +00:00

18 lines
377 B
Kotlin
Vendored

sealed class Sealed(val x: Int) {
object First: Sealed(12)
open class NonFirst(x: Int, val y: Int): Sealed(x) {
object Second: NonFirst(34, 2)
object Third: NonFirst(56, 3)
}
object Last: Sealed(78)
}
fun foo(s: Sealed): Int {
return when(s) {
!is Sealed.First -> 1
!is Sealed.Last -> 0
// no else required
}
}