Files
kotlin-fork/compiler/testData/codegen/box/fir/unqualifiedEnum.kt
T
Kirill Rakhman cf2ef443f4 [FIR] Introduce a feature flag for context-sensitive enum resolution
The feature was previously enabled unconditionally in K2 which
triggered a bug when an enum has an entry with the same name as itself.

#KT-58897 Fixed
#KT-52774
2023-05-30 11:59:56 +00:00

34 lines
555 B
Kotlin
Vendored

// TARGET_BACKEND: JVM_IR
// IGNORE_BACKEND_K1: JVM_IR
// WITH_STDLIB
// LANGUAGE: +ContextSensitiveEnumResolutionInWhen
enum class Rainbow {
RED,
ORANGE,
YELLOW,
GREEN,
CYAN,
BLUE,
VIOLET
}
fun sym(r: Rainbow) = when (r) {
RED -> 'r'
ORANGE -> 'o'
YELLOW -> 'y'
GREEN -> 'g'
CYAN -> 'c'
BLUE -> 'b'
VIOLET -> 'v'
}
fun box(): String {
val s = buildString {
for (value in Rainbow.values()) {
append(sym(value))
}
}
return if (s == "roygcbv") "OK" else s
}