Files
kotlin-fork/compiler/testData/codegen/box/when/whenSubjectVariable/sparseIntSwitchWithSubjectVariable.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

20 lines
394 B
Kotlin
Vendored

// KJS_WITH_FULL_RUNTIME
// !LANGUAGE: +VariableDeclarationInWhenSubject
// WITH_RUNTIME
fun sparse(x: Int): Int {
return when (val xx = (x % 4) * 100) {
100 -> 1
200 -> xx / 100
300 -> 3
else -> 4
}
}
fun box(): String {
var result = (0..3).map(::sparse).joinToString()
if (result != "4, 1, 2, 3") return "sparse:" + result
return "OK"
}