Implicit exhaustive whens now have exception in else branch #KT-8700 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
011a9f23b9
commit
7d6ccc40c2
@@ -0,0 +1,14 @@
|
||||
enum class A { V }
|
||||
|
||||
fun box(): String {
|
||||
val a: A = A.V
|
||||
val b: Boolean
|
||||
when (a) {
|
||||
A.V -> b = true
|
||||
}
|
||||
return if (b) "OK" else "FAIL"
|
||||
}
|
||||
|
||||
// 0 TABLESWITCH
|
||||
// 1 LOOKUPSWITCH
|
||||
// 1 ATHROW
|
||||
@@ -0,0 +1,12 @@
|
||||
enum class A { V }
|
||||
|
||||
fun box(): String {
|
||||
val a: A = A.V
|
||||
when (a) {
|
||||
A.V -> return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
// 0 TABLESWITCH
|
||||
// 1 LOOKUPSWITCH
|
||||
// 1 ATHROW
|
||||
@@ -0,0 +1,19 @@
|
||||
sealed class A {
|
||||
object B : A()
|
||||
|
||||
class C : A()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val a: A = A.C()
|
||||
val b: Boolean
|
||||
when (a) {
|
||||
A.B -> b = true
|
||||
is A.C -> b = false
|
||||
}
|
||||
return if (!b) "OK" else "FAIL"
|
||||
}
|
||||
|
||||
// 0 TABLESWITCH
|
||||
// 0 LOOKUPSWITCH
|
||||
// 1 ATHROW
|
||||
Reference in New Issue
Block a user