[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:
Generated
+23
@@ -5161,6 +5161,29 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/companion")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Companion extends AbstractFirBlackBoxCodegenTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.JVM_IR, testDataFilePath, "// IGNORE_BACKEND_FIR: ");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInCompanion() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/companion"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, 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)
|
||||
|
||||
Generated
+20
@@ -966,11 +966,26 @@ public class FirBytecodeTextTestGenerated extends AbstractFirBytecodeTextTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeText/companion"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, 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 FirBytecodeTextTestGenerated extends AbstractFirBytecodeTextTest {
|
||||
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");
|
||||
|
||||
Reference in New Issue
Block a user