Files
kotlin-fork/compiler/testData/codegen/box/when/enumOptimization/kt15806.kt
T
Nikolay Lunyak bcfafc601e Add EnumEntries to minimal-stdlib-for-tests
This change allows to revert adding `WITH_STDLIB` directive
to tests which happened at `a9343aeb`.

Co-authored-by: Alexander Udalov <Alexander.Udalov@jetbrains.com>
2023-03-02 10:23:38 +00:00

30 lines
707 B
Kotlin
Vendored

// IGNORE_BACKEND_K2: JS_IR
// CHECK_CASES_COUNT: function=doTheThing count=2 TARGET_BACKENDS=JS
// CHECK_CASES_COUNT: function=doTheThing count=0 IGNORED_BACKENDS=JS
// CHECK_IF_COUNT: function=doTheThing count=2 TARGET_BACKENDS=JS
// CHECK_IF_COUNT: function=doTheThing count=4 IGNORED_BACKENDS=JS
private fun Any?.doTheThing(): String {
when (this) {
is String -> return this
is Level -> {
when (this) {
Level.O -> return Level.O.name
Level.K -> return Level.K.name
}
}
else -> return "fail"
}
}
enum class Level {
O,
K
}
fun box(): String {
return "O".doTheThing() + Level.K.doTheThing()
}