Correct CFA order for enums: first own members, then entries, and at last companion object members #KT-6054 Fixed
(cherry picked from commit 94d3b4c)
This commit is contained in:
committed by
Mikhail Glukhikh
parent
1bc7b4e363
commit
13e64c18d9
+24
-2
@@ -29,7 +29,8 @@ enum class D(val x: Int) {
|
||||
}
|
||||
|
||||
enum class E(val v: Int) {
|
||||
E1(Nested.<!UNINITIALIZED_VARIABLE!>COPY<!>);
|
||||
// KT-11769 related: there is no predictable initialization order for enum entry with non-companion object
|
||||
E1(Nested.COPY);
|
||||
|
||||
object Nested {
|
||||
val COPY = E1.v
|
||||
@@ -41,4 +42,25 @@ object Object1 {
|
||||
object Object2 {
|
||||
val z: Any = Object1.y
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// From KT-11769
|
||||
enum class Fruit(personal: Int) {
|
||||
APPLE(1);
|
||||
|
||||
companion object {
|
||||
val common = 20
|
||||
}
|
||||
|
||||
val score = personal + <!UNINITIALIZED_VARIABLE!>common<!>
|
||||
}
|
||||
|
||||
// From KT-6054
|
||||
enum class MyEnum {
|
||||
A, B;
|
||||
val x = when(<!DEBUG_INFO_LEAKING_THIS!>this<!>) {
|
||||
<!UNINITIALIZED_ENUM_ENTRY!>A<!> -> 1
|
||||
<!UNINITIALIZED_ENUM_ENTRY!>B<!> -> 2
|
||||
else -> 3
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user