[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:
Mark Punzalan
2020-02-14 13:19:59 -08:00
committed by Dmitry Petrov
parent 56c819f06e
commit 64141b8b38
17 changed files with 464 additions and 8 deletions
@@ -3458,6 +3458,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
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");
@@ -17474,6 +17479,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
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");