[JVM IR] Fix issue where fields are not being set to their default
values within initializer blocks.
The issue occurs in code like this:
```
class C {
var b = true
init {
b = false // Missing PUTFIELD for this statement
}
}
```
Added a new statement origin for field initialization (at declaration)
instead of relying on `origin == null` in ExpressionCodegen to determine
whether to generate the initializations.
This was unintentionally broken in
d68a1898d0.
This commit is contained in:
committed by
Dmitry Petrov
parent
56c819f06e
commit
64141b8b38
Generated
+10
@@ -2758,6 +2758,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/classes/initializerBlockDImpl.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("initializerBlockResetToDefault.kt")
|
||||
public void testInitializerBlockResetToDefault() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/classes/initializerBlockResetToDefault.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("innerClass.kt")
|
||||
public void testInnerClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/classes/innerClass.kt");
|
||||
@@ -13324,6 +13329,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/objects/initializationOrder.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("initializerBlockResetToDefault.kt")
|
||||
public void testInitializerBlockResetToDefault() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/objects/initializerBlockResetToDefault.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interfaceCompanion.kt")
|
||||
public void testInterfaceCompanion() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/objects/interfaceCompanion.kt");
|
||||
|
||||
+10
@@ -2758,6 +2758,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/classes/initializerBlockDImpl.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("initializerBlockResetToDefault.kt")
|
||||
public void testInitializerBlockResetToDefault() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/classes/initializerBlockResetToDefault.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("innerClass.kt")
|
||||
public void testInnerClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/classes/innerClass.kt");
|
||||
@@ -13389,6 +13394,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/objects/initializationOrder.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("initializerBlockResetToDefault.kt")
|
||||
public void testInitializerBlockResetToDefault() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/objects/initializerBlockResetToDefault.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interfaceCompanion.kt")
|
||||
public void testInterfaceCompanion() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/objects/interfaceCompanion.kt");
|
||||
|
||||
Reference in New Issue
Block a user