[FE] Properly support sealed interfaces in exhaustiveness checker
#KT-20423
This commit is contained in:
committed by
TeamCityServer
parent
9609954560
commit
8e9e34350f
-38
@@ -1,38 +0,0 @@
|
||||
// ISSUE: KT-20423
|
||||
// !LANGUAGE: +FreedomForSealedClasses +SealedInterfaces
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
|
||||
sealed interface Base
|
||||
|
||||
interface A : Base
|
||||
|
||||
sealed class B : Base {
|
||||
class First : B()
|
||||
class Second : B()
|
||||
}
|
||||
|
||||
enum class C : Base {
|
||||
SomeValue, AnotherValue
|
||||
}
|
||||
|
||||
object D : Base
|
||||
|
||||
fun test_1(base: Base) {
|
||||
val x = when (base) {
|
||||
is A -> 1
|
||||
is B -> 2
|
||||
is C -> 3
|
||||
is D -> 4
|
||||
}
|
||||
}
|
||||
|
||||
fun test_2(base: Base) {
|
||||
val x = when (base) {
|
||||
is A -> 1
|
||||
is B.First -> 2
|
||||
is B.Second -> 3
|
||||
C.SomeValue -> 4
|
||||
C.AnotherValue -> 5
|
||||
D -> 6
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// ISSUE: KT-20423
|
||||
// !LANGUAGE: +FreedomForSealedClasses +SealedInterfaces
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
@@ -27,7 +28,7 @@ fun test_1(base: Base) {
|
||||
}
|
||||
|
||||
fun test_2(base: Base) {
|
||||
val x = <!NO_ELSE_IN_WHEN!>when<!> (base) {
|
||||
val x = when (base) {
|
||||
is A -> 1
|
||||
is B.First -> 2
|
||||
is B.Second -> 3
|
||||
|
||||
Reference in New Issue
Block a user