mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 15:53:19 +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,26 @@
|
||||
enum class Season {
|
||||
WINTER
|
||||
SPRING
|
||||
SUMMER
|
||||
AUTUMN
|
||||
}
|
||||
|
||||
fun foo1(x : Season?) : String {
|
||||
when(x) {
|
||||
Season.AUTUMN, Season.SPRING -> return "autumn_or_spring";
|
||||
Season.SUMMER, null -> return "summer_or_null"
|
||||
}
|
||||
|
||||
return "other"
|
||||
}
|
||||
|
||||
fun foo2(x : Season?) : String {
|
||||
when(x) {
|
||||
Season.AUTUMN, Season.SPRING -> return "autumn_or_spring";
|
||||
Season.SUMMER -> return "summer"
|
||||
}
|
||||
|
||||
return "other"
|
||||
}
|
||||
|
||||
// 2 TABLESWITCH
|
||||
Reference in New Issue
Block a user