Files
kotlin-fork/compiler/testData/codegen/box/when/switchOptimizationMultipleConditions.kt
T
Juan Chen 9dd8eda1c9 [FIR]: fix library methods in packages
Library methods such as 'listOf' are resolved
to have the package fragments as their parents,
but JVM expects their containing file classes as parents.
This fix generates those file classes and
uses them as parent replacements for such library methods.
2020-02-20 14:24:02 +03:00

21 lines
417 B
Kotlin
Vendored

// WITH_RUNTIME
// KJS_WITH_FULL_RUNTIME
// CHECK_CASES_COUNT: function=foo count=9
// CHECK_IF_COUNT: function=foo count=0
fun foo(x: Int): Int {
return when (x) {
1, 2, 3 -> 1
4, 5, 6 -> 2
7, 8, 9 -> 3
else -> 4
}
}
fun box(): String {
var result = (0..10).map(::foo).joinToString()
if (result != "4, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4") return result
return "OK"
}