JVM: Don't generate accessors to companions in earlier language versions
This commit is contained in:
@@ -2862,7 +2862,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
}
|
||||
}
|
||||
|
||||
private static CodegenContext getContextForCompanionObjectAccessorIfRequiredOrNull(
|
||||
private CodegenContext getContextForCompanionObjectAccessorIfRequiredOrNull(
|
||||
@NotNull ClassDescriptor companionObjectDescriptor,
|
||||
@NotNull CodegenContext contextBeforeInline
|
||||
) {
|
||||
@@ -2870,6 +2870,10 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!state.getLanguageVersionSettings().supportsFeature(LanguageFeature.ProperVisibilityForCompanionObjectInstanceField)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int accessFlag = AsmUtil.getVisibilityAccessFlag(companionObjectDescriptor);
|
||||
|
||||
CodegenContext context = contextBeforeInline.getFirstCrossInlineOrNonInlineContext();
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// !LANGUAGE: +ProperVisibilityForCompanionObjectInstanceField
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// ^ TODO implement ProperVisibilityForCompanionObjectInstanceField feature support in JMV_IR
|
||||
|
||||
class Host {
|
||||
private companion object {
|
||||
fun foo() = 1
|
||||
}
|
||||
|
||||
fun test() = { foo() }
|
||||
}
|
||||
|
||||
// 1 synthetic access\$
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// !LANGUAGE: -ProperVisibilityForCompanionObjectInstanceField
|
||||
|
||||
class Host {
|
||||
private companion object {
|
||||
fun foo() = 1
|
||||
}
|
||||
|
||||
fun test() = { foo() }
|
||||
}
|
||||
|
||||
// 0 synthetic access\$
|
||||
@@ -920,6 +920,16 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
|
||||
public void testKt14258_5() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/companion/kt14258_5.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("privateCompanionObjectAccessors_after.kt")
|
||||
public void testPrivateCompanionObjectAccessors_after() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/companion/privateCompanionObjectAccessors_after.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("privateCompanionObjectAccessors_before.kt")
|
||||
public void testPrivateCompanionObjectAccessors_before() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/companion/privateCompanionObjectAccessors_before.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/bytecodeText/conditions")
|
||||
|
||||
+10
@@ -920,6 +920,16 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest {
|
||||
public void testKt14258_5() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/companion/kt14258_5.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("privateCompanionObjectAccessors_after.kt")
|
||||
public void testPrivateCompanionObjectAccessors_after() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/companion/privateCompanionObjectAccessors_after.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("privateCompanionObjectAccessors_before.kt")
|
||||
public void testPrivateCompanionObjectAccessors_before() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/companion/privateCompanionObjectAccessors_before.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/bytecodeText/conditions")
|
||||
|
||||
Reference in New Issue
Block a user