JVM_IR: Do not add redundant field initializers.

Initializers are "set field" expressions and are considered redundant
when they are:
1. In the primary constructor; and
2. Set the field to `0`, `false`, or `null`; and
3. Have a `null` origin. I.e., not in an initializer block or
constructor body, and therefore the field could not have been set by a
prior expression.
This commit is contained in:
Mark Punzalan
2019-01-30 16:18:59 -08:00
committed by max-kammerer
parent 9e8972f1f9
commit e91a16556c
4 changed files with 149 additions and 1 deletions
@@ -329,6 +329,11 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
runTest("compiler/testData/codegen/bytecodeText/redundantInitializerNumber.kt");
}
@TestMetadata("redundantValInitializer.kt")
public void testRedundantValInitializer() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/redundantValInitializer.kt");
}
@TestMetadata("reifiedAsCheck.kt")
public void testReifiedAsCheck() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/reifiedAsCheck.kt");