Files
kotlin-fork/compiler/fir/analysis-tests/testData/resolve/unqualifiedEnum/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

39 lines
745 B
Kotlin
Vendored

// LANGUAGE: +ContextSensitiveEnumResolutionInWhen
package test
enum class Sample {
FIRST, SECOND, THIRD;
}
fun trivial(s: Sample): Int {
return when (s) {
FIRST -> 1
SECOND -> 2
THIRD -> 3
}
}
fun shouldNotWork(s: Sample): Int {
return when {
s == <!UNRESOLVED_REFERENCE!>FIRST<!> -> 1
s == <!UNRESOLVED_REFERENCE!>SECOND<!> -> 2
s == <!UNRESOLVED_REFERENCE!>THIRD<!> -> 3
else -> 0
}
}
class Container {
val SECOND = test.Sample.SECOND
fun priority(s: Sample): Int {
val FIRST = test.Sample.THIRD
return when (s) {
FIRST -> 3
SECOND -> 2
test.Sample.FIRST -> 1
else -> 0
}
}
}