[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
|
isStatic = true
|
||||||
}.apply {
|
}.apply {
|
||||||
parent = irClass
|
parent = irClass
|
||||||
val builder = context.createIrBuilder(irClass.symbol)
|
initializer = null
|
||||||
initializer = builder.run { irExprBody(irImplicitCast(irNull(), type)) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enumEntry.correspondingField = result
|
enumEntry.correspondingField = result
|
||||||
@@ -407,8 +406,7 @@ class EnumClassCreateInitializerLowering(val context: JsIrBackendContext) : Decl
|
|||||||
isStatic = true
|
isStatic = true
|
||||||
}.apply {
|
}.apply {
|
||||||
parent = irClass
|
parent = irClass
|
||||||
val builder = context.createIrBuilder(irClass.symbol)
|
initializer = null
|
||||||
initializer = builder.run { irExprBody(irBoolean(false)) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createInitEntryInstancesFun(irClass: IrClass, entryInstancesInitializedField: IrField): IrSimpleFunction =
|
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);
|
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")
|
@TestMetadata("kt2470.kt")
|
||||||
public void testKt2470() throws Exception {
|
public void testKt2470() throws Exception {
|
||||||
runTest("js/js.translator/testData/box/regression/kt2470.kt");
|
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);
|
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")
|
@TestMetadata("kt2470.kt")
|
||||||
public void testKt2470() throws Exception {
|
public void testKt2470() throws Exception {
|
||||||
runTest("js/js.translator/testData/box/regression/kt2470.kt");
|
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