Implicit exhaustive whens now have exception in else branch #KT-8700 Fixed

This commit is contained in:
Mikhail Glukhikh
2015-12-04 18:43:44 +03:00
committed by Mikhail Glukhikh
parent 011a9f23b9
commit 7d6ccc40c2
16 changed files with 167 additions and 18 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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