mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 15:53:19 +00:00
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
14
compiler/testData/codegen/bytecodeText/when/exhaustiveWhenInitialization.kt
vendored
Normal file
14
compiler/testData/codegen/bytecodeText/when/exhaustiveWhenInitialization.kt
vendored
Normal 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
|
||||
12
compiler/testData/codegen/bytecodeText/when/exhaustiveWhenReturn.kt
vendored
Normal file
12
compiler/testData/codegen/bytecodeText/when/exhaustiveWhenReturn.kt
vendored
Normal 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
|
||||
19
compiler/testData/codegen/bytecodeText/when/sealedWhenInitialization.kt
vendored
Normal file
19
compiler/testData/codegen/bytecodeText/when/sealedWhenInitialization.kt
vendored
Normal 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
|
||||
Reference in New Issue
Block a user