KT-36973 Keep private default interface members private

This commit is contained in:
Dmitry Petrov
2020-03-18 12:22:42 +03:00
parent 1c24a97b9e
commit dd27b3d4f1
12 changed files with 74 additions and 5 deletions
@@ -27022,6 +27022,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/traits/kt3579_2.kt");
}
@TestMetadata("kt36973.kt")
public void testKt36973() throws Exception {
runTest("compiler/testData/codegen/box/traits/kt36973.kt");
}
@TestMetadata("kt5393.kt")
public void testKt5393() throws Exception {
runTest("compiler/testData/codegen/box/traits/kt5393.kt");
@@ -233,11 +233,10 @@ class JvmDeclarationFactory(
// Old backend doesn't generate ACC_FINAL on DefaultImpls methods.
modality = Modality.OPEN,
// Interface functions are always public, with one exception: clone in Cloneable, which is protected. However, Cloneable
// has no DefaultImpls, so this merely replicates the incorrect behavior of the old backend. We should rather not generate
// a bridge to clone when interface inherits from Cloneable at all. Below, we force everything, including those bridges,
// to be public so that we won't try to generate synthetic accessor for them.
visibility = Visibilities.PUBLIC,
// Interface functions are public or private, with one exception: clone in Cloneable, which is protected.
// However, Cloneable has no DefaultImpls, so this merely replicates the incorrect behavior of the old backend.
// We should rather not generate a bridge to clone when interface inherits from Cloneable at all.
visibility = if (interfaceFun.visibility == Visibilities.PRIVATE) Visibilities.PRIVATE else Visibilities.PUBLIC,
typeParametersFromContext = parent.typeParameters
)
+15
View File
@@ -0,0 +1,15 @@
// IGNORE_BACKEND_FIR: JVM_IR
// FILE: kt36973.kt
import other.*
class C : IFoo
fun box() = C().foo()()
// FILE: IFoo.kt
package other
interface IFoo {
fun foo() = { bar() }
private fun bar() = "OK"
}
@@ -0,0 +1,4 @@
interface A {
private fun foo() {}
private val x get() = 1
}
@@ -0,0 +1,11 @@
@kotlin.Metadata
public final class A$DefaultImpls {
inner class A$DefaultImpls
private static method foo(p0: A): void
private static method getX(p0: A): int
}
@kotlin.Metadata
public interface A {
inner class A$DefaultImpls
}
@@ -28538,6 +28538,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/traits/kt3579_2.kt");
}
@TestMetadata("kt36973.kt")
public void testKt36973() throws Exception {
runTest("compiler/testData/codegen/box/traits/kt36973.kt");
}
@TestMetadata("kt5393.kt")
public void testKt5393() throws Exception {
runTest("compiler/testData/codegen/box/traits/kt5393.kt");
@@ -104,6 +104,11 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest {
runTest("compiler/testData/codegen/bytecodeListing/platformTypes.kt");
}
@TestMetadata("privateDefaultImpls.kt")
public void testPrivateDefaultImpls() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/privateDefaultImpls.kt");
}
@TestMetadata("privateDefaultSetter.kt")
public void testPrivateDefaultSetter() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/privateDefaultSetter.kt");
@@ -27355,6 +27355,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/traits/kt3579_2.kt");
}
@TestMetadata("kt36973.kt")
public void testKt36973() throws Exception {
runTest("compiler/testData/codegen/box/traits/kt36973.kt");
}
@TestMetadata("kt5393.kt")
public void testKt5393() throws Exception {
runTest("compiler/testData/codegen/box/traits/kt5393.kt");
@@ -27022,6 +27022,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/traits/kt3579_2.kt");
}
@TestMetadata("kt36973.kt")
public void testKt36973() throws Exception {
runTest("compiler/testData/codegen/box/traits/kt36973.kt");
}
@TestMetadata("kt5393.kt")
public void testKt5393() throws Exception {
runTest("compiler/testData/codegen/box/traits/kt5393.kt");
@@ -104,6 +104,11 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes
runTest("compiler/testData/codegen/bytecodeListing/platformTypes.kt");
}
@TestMetadata("privateDefaultImpls.kt")
public void testPrivateDefaultImpls() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/privateDefaultImpls.kt");
}
@TestMetadata("privateDefaultSetter.kt")
public void testPrivateDefaultSetter() throws Exception {
runTest("compiler/testData/codegen/bytecodeListing/privateDefaultSetter.kt");
@@ -21923,6 +21923,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/traits/kt3579_2.kt");
}
@TestMetadata("kt36973.kt")
public void testKt36973() throws Exception {
runTest("compiler/testData/codegen/box/traits/kt36973.kt");
}
@TestMetadata("kt5393.kt")
public void testKt5393() throws Exception {
runTest("compiler/testData/codegen/box/traits/kt5393.kt");
@@ -21983,6 +21983,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/traits/kt3579_2.kt");
}
@TestMetadata("kt36973.kt")
public void testKt36973() throws Exception {
runTest("compiler/testData/codegen/box/traits/kt36973.kt");
}
@TestMetadata("kt5393.kt")
public void testKt5393() throws Exception {
runTest("compiler/testData/codegen/box/traits/kt5393.kt");