[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
@@ -966,11 +966,26 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeText/companion"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
}
@TestMetadata("directAccessToBackingField.kt")
public void testDirectAccessToBackingField() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/companion/directAccessToBackingField.kt");
}
@TestMetadata("floatingPointCompanionAccess.kt")
public void testFloatingPointCompanionAccess() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/companion/floatingPointCompanionAccess.kt");
}
@TestMetadata("inlineFunctionCompanionPropertyAccess.kt")
public void testInlineFunctionCompanionPropertyAccess() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/companion/inlineFunctionCompanionPropertyAccess.kt");
}
@TestMetadata("inlineFunctionObjectCompanionPropertyAccess.kt")
public void testInlineFunctionObjectCompanionPropertyAccess() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/companion/inlineFunctionObjectCompanionPropertyAccess.kt");
}
@TestMetadata("kt14258_1.kt")
public void testKt14258_1() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/companion/kt14258_1.kt");
@@ -996,6 +1011,11 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
runTest("compiler/testData/codegen/bytecodeText/companion/kt14258_5.kt");
}
@TestMetadata("nonDefaultAccessors.kt")
public void testNonDefaultAccessors() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/companion/nonDefaultAccessors.kt");
}
@TestMetadata("privateCompanionObjectAccessors_after.kt")
public void testPrivateCompanionObjectAccessors_after() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/companion/privateCompanionObjectAccessors_after.kt");