mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-09 00:21:47 +00:00
When2Switch: generate ifnonnull check for nullable values before *switch-opcode
This commit is contained in:
committed by
Evgeny Gerashchenko
parent
706bbd7b72
commit
8d8c3d2b9e
@@ -0,0 +1,18 @@
|
||||
fun foo1(x : String?) : String {
|
||||
when (x) {
|
||||
"abc", "cde" -> return "abc_cde"
|
||||
"efg", "ghi", null -> return "efg_ghi"
|
||||
}
|
||||
|
||||
return "other"
|
||||
}
|
||||
|
||||
fun foo2(x : String?) : String {
|
||||
when (x) {
|
||||
"abc", "cde" -> return "abc_cde"
|
||||
"efg", "ghi" -> return "efg_ghi"
|
||||
else -> return "other"
|
||||
}
|
||||
}
|
||||
|
||||
// 2 LOOKUPSWITCH
|
||||
Reference in New Issue
Block a user