[JS IR BE] Fix enum entry initialization
Keep helper fields uninitialized. This way thier initialization would not depend on field initialization order.
This commit is contained in:
+2
-4
@@ -343,8 +343,7 @@ class EnumEntryInstancesLowering(val context: JsIrBackendContext) : DeclarationT
|
||||
isStatic = true
|
||||
}.apply {
|
||||
parent = irClass
|
||||
val builder = context.createIrBuilder(irClass.symbol)
|
||||
initializer = builder.run { irExprBody(irImplicitCast(irNull(), type)) }
|
||||
initializer = null
|
||||
}
|
||||
|
||||
enumEntry.correspondingField = result
|
||||
@@ -407,8 +406,7 @@ class EnumClassCreateInitializerLowering(val context: JsIrBackendContext) : Decl
|
||||
isStatic = true
|
||||
}.apply {
|
||||
parent = irClass
|
||||
val builder = context.createIrBuilder(irClass.symbol)
|
||||
initializer = builder.run { irExprBody(irBoolean(false)) }
|
||||
initializer = null
|
||||
}
|
||||
|
||||
private fun createInitEntryInstancesFun(irClass: IrClass, entryInstancesInitializedField: IrField): IrSimpleFunction =
|
||||
|
||||
+5
@@ -6804,6 +6804,11 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/regression"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@TestMetadata("enumEntryInitOrder.kt")
|
||||
public void testEnumEntryInitOrder() throws Exception {
|
||||
runTest("js/js.translator/testData/box/regression/enumEntryInitOrder.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt2470.kt")
|
||||
public void testKt2470() throws Exception {
|
||||
runTest("js/js.translator/testData/box/regression/kt2470.kt");
|
||||
|
||||
+5
@@ -6859,6 +6859,11 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/regression"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS, true);
|
||||
}
|
||||
|
||||
@TestMetadata("enumEntryInitOrder.kt")
|
||||
public void testEnumEntryInitOrder() throws Exception {
|
||||
runTest("js/js.translator/testData/box/regression/enumEntryInitOrder.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt2470.kt")
|
||||
public void testKt2470() throws Exception {
|
||||
runTest("js/js.translator/testData/box/regression/kt2470.kt");
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
// EXPECTED_REACHABLE_NODES: 1309
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
|
||||
enum class E { A, B }
|
||||
val x: Any = E.A
|
||||
|
||||
fun box(): String {
|
||||
if (x !== E.A) return "Fail"
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user