05ff2b1292
FIR translates:
```
when (x) {
1, 2, 3 -> action
else -> other_action
}
```
to an IR structure with nested ors:
```
if ((x == 1 || x == 2) || (x == 3)) action
else other_action
```
This change allows that to turn into switch instructions in the
JVM backend.
36 lines
759 B
Kotlin
Vendored
36 lines
759 B
Kotlin
Vendored
package abc.foo
|
|
|
|
enum class Season {
|
|
WINTER,
|
|
SPRING,
|
|
SUMMER,
|
|
AUTUMN
|
|
}
|
|
|
|
class A {
|
|
public fun bar1(x : Season) : String {
|
|
when (x) {
|
|
Season.WINTER, Season.SPRING -> return "winter_spring"
|
|
Season.SPRING -> return "spring"
|
|
Season.SUMMER -> return "summer"
|
|
}
|
|
|
|
return "autumn";
|
|
}
|
|
|
|
public fun bar2(y : Season) : String {
|
|
return bar3(y) { x ->
|
|
when (x) {
|
|
Season.WINTER, Season.SPRING -> "winter_spring"
|
|
Season.SPRING -> "spring"
|
|
Season.SUMMER -> "summer"
|
|
else -> "autumn"
|
|
}
|
|
}
|
|
}
|
|
|
|
private fun bar3(x : Season, block : (Season) -> String) = block(x)
|
|
}
|
|
|
|
// 2 TABLESWITCH
|