[JVM_IR] Use direct field access to backing fields on current class.

The current backend uses direct field access to the backing field
instead of calling the companion object accessor, which calls
an accessibility bridge, which then gets the field for code such as:

```
class A {
  companion object {
    val s: String = "OK"
  }

  // f uses direct access to the A.s backing field.
  fun f() = s
}
```

This change does the same for the IR backend.
This commit is contained in:
Mads Ager
2020-11-25 14:36:40 +01:00
committed by max-kammerer
parent 1d14926444
commit c922484758
19 changed files with 524 additions and 6 deletions
@@ -5161,6 +5161,29 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
}
}
@TestMetadata("compiler/testData/codegen/box/companion")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Companion extends AbstractBlackBoxCodegenTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
}
public void testAllFilesPresentInCompanion() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/companion"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
}
@TestMetadata("delegatedPropertyOnCompanion.kt")
public void testDelegatedPropertyOnCompanion() throws Exception {
runTest("compiler/testData/codegen/box/companion/delegatedPropertyOnCompanion.kt");
}
@TestMetadata("inlineFunctionCompanionPropertyAccess.kt")
public void testInlineFunctionCompanionPropertyAccess() throws Exception {
runTest("compiler/testData/codegen/box/companion/inlineFunctionCompanionPropertyAccess.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/compatibility")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)