[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
@@ -339,6 +339,21 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
runTest("compiler/testData/codegen/bytecodeText/redundantValInitializer.kt");
}
@TestMetadata("redundantValInitializerInObject.kt")
public void testRedundantValInitializerInObject() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/redundantValInitializerInObject.kt");
}
@TestMetadata("redundantVarInitializer.kt")
public void testRedundantVarInitializer() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/redundantVarInitializer.kt");
}
@TestMetadata("redundantVarInitializerInObject.kt")
public void testRedundantVarInitializerInObject() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/redundantVarInitializerInObject.kt");
}
@TestMetadata("reifiedAsCheck.kt")
public void testReifiedAsCheck() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/reifiedAsCheck.kt");