Fix modifiers generation for companion objects
when language verion is 1.3 #KT-23002: Fixed
This commit is contained in:
@@ -897,7 +897,15 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
deprecatedFieldForInvisibleCompanionObject &&
|
||||
!properVisibilityForCompanionObjectInstanceField &&
|
||||
(properFieldVisibilityFlag & (ACC_PRIVATE | ACC_PROTECTED)) != 0;
|
||||
int fieldAccessFlags = ACC_PUBLIC | ACC_STATIC | ACC_FINAL;
|
||||
boolean doNotGeneratePublic =
|
||||
properVisibilityForCompanionObjectInstanceField && (properFieldVisibilityFlag & (ACC_PRIVATE | ACC_PROTECTED)) != 0;
|
||||
int fieldAccessFlags;
|
||||
if (doNotGeneratePublic) {
|
||||
fieldAccessFlags = ACC_STATIC | ACC_FINAL;
|
||||
}
|
||||
else {
|
||||
fieldAccessFlags = ACC_PUBLIC | ACC_STATIC | ACC_FINAL;
|
||||
}
|
||||
if (properVisibilityForCompanionObjectInstanceField) {
|
||||
fieldAccessFlags |= properFieldVisibilityFlag;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
// LANGUAGE_VERSION: 1.3
|
||||
|
||||
class Test {
|
||||
private companion object {
|
||||
val res = "OK"
|
||||
}
|
||||
fun res() = res
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return Test().res()
|
||||
}
|
||||
@@ -22,7 +22,7 @@ final class TestPrivateCompanion$Test {
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class TestPrivateCompanion {
|
||||
public private final static field Test: TestPrivateCompanion$Test
|
||||
private final static field Test: TestPrivateCompanion$Test
|
||||
inner class TestPrivateCompanion$Test
|
||||
static method <clinit>(): void
|
||||
public method <init>(): void
|
||||
@@ -37,7 +37,7 @@ public final class TestProtectedCompanion$Test {
|
||||
|
||||
@kotlin.Metadata
|
||||
public class TestProtectedCompanion {
|
||||
public protected final static field Test: TestProtectedCompanion$Test
|
||||
protected final static field Test: TestProtectedCompanion$Test
|
||||
inner class TestProtectedCompanion$Test
|
||||
static method <clinit>(): void
|
||||
public method <init>(): void
|
||||
|
||||
Generated
+6
@@ -4454,6 +4454,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/compatibility/dataClassEqualsHashCodeToString.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("privateCompanionObject.kt")
|
||||
public void testPrivateCompanionObject() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/compatibility/privateCompanionObject.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/constants")
|
||||
|
||||
+6
@@ -4454,6 +4454,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/compatibility/dataClassEqualsHashCodeToString.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("privateCompanionObject.kt")
|
||||
public void testPrivateCompanionObject() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/compatibility/privateCompanionObject.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/constants")
|
||||
|
||||
+6
@@ -4454,6 +4454,12 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/compatibility/dataClassEqualsHashCodeToString.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("privateCompanionObject.kt")
|
||||
public void testPrivateCompanionObject() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/compatibility/privateCompanionObject.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/constants")
|
||||
|
||||
+6
@@ -5054,6 +5054,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/compatibility/dataClassEqualsHashCodeToString.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("privateCompanionObject.kt")
|
||||
public void testPrivateCompanionObject() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/compatibility/privateCompanionObject.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/constants")
|
||||
|
||||
Reference in New Issue
Block a user