Files
kotlin-fork/compiler/testData/codegen/box/when/enumOptimization/enumInsideClassObject.kt
T
Mikhail Glukhikh a4c7619c89 [FIR2IR] Introduce & use FirBuiltInsPackageFragment
Without this commit, JVM name mapping logic in BE does not work for FIR,
because FIR cannot use old BuiltInsPackageFragmentImpl descriptor.
In this commit we add our own implementation thus fixing
a pack of FIR black box tests.
2020-03-24 10:37:53 +03:00

34 lines
802 B
Kotlin
Vendored

// WITH_RUNTIME
// CHECK_CASES_COUNT: function=foo count=3
// CHECK_IF_COUNT: function=foo count=0
import kotlin.test.assertEquals
class A {
companion object {
enum class Season {
WINTER,
SPRING,
SUMMER,
AUTUMN
}
}
}
fun foo(x : A.Companion.Season) : String {
return when (x) {
A.Companion.Season.WINTER -> "winter"
A.Companion.Season.SPRING -> "spring"
A.Companion.Season.SUMMER -> "summer"
else -> "other"
}
}
fun box() : String {
assertEquals("winter", foo(A.Companion.Season.WINTER))
assertEquals("spring", foo(A.Companion.Season.SPRING))
assertEquals("summer", foo(A.Companion.Season.SUMMER))
assertEquals("other", foo(A.Companion.Season.AUTUMN))
return "OK"
}