Files
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

35 lines
533 B
Kotlin
Vendored

// LANGUAGE: +ContextSensitiveEnumResolutionInWhen
// FILE: first.kt
package first
enum class First {
ONE, TWO;
}
val THREE = First.ONE
// FILE: second.kt
package second
import first.First
import first.THREE
enum class Second {
THREE, FOUR;
}
val ONE = Second.THREE
fun foo(f: First) = <!NO_ELSE_IN_WHEN!>when<!> (f) {
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>ONE<!> -> 1
TWO -> 2
}
fun bar(s: Second) = <!NO_ELSE_IN_WHEN!>when<!> (s) {
<!INCOMPATIBLE_ENUM_COMPARISON_ERROR!>THREE<!> -> 3
FOUR -> 4
}