KT-53007 Fix accessibility checks when calling a protected member via super@Outer
This commit is contained in:
+6
@@ -5781,6 +5781,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/classes/kt508.kt");
|
runTest("compiler/testData/codegen/box/classes/kt508.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt53007.kt")
|
||||||
|
public void testKt53007() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/classes/kt53007.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("kt5347.kt")
|
@TestMetadata("kt5347.kt")
|
||||||
public void testKt5347() throws Exception {
|
public void testKt5347() throws Exception {
|
||||||
|
|||||||
+1
-1
@@ -91,8 +91,8 @@ internal class SyntheticAccessorLowering(val context: JvmBackendContext) : FileL
|
|||||||
val scopeClassOrPackage = inlineScopeResolver.findContainer(currentScope!!.irElement) ?: return false
|
val scopeClassOrPackage = inlineScopeResolver.findContainer(currentScope!!.irElement) ?: return false
|
||||||
val samePackage = ownerClass.getPackageFragment().fqName == scopeClassOrPackage.getPackageFragment()?.fqName
|
val samePackage = ownerClass.getPackageFragment().fqName == scopeClassOrPackage.getPackageFragment()?.fqName
|
||||||
return when {
|
return when {
|
||||||
jvmVisibility == 0 /* package only */ -> samePackage
|
|
||||||
jvmVisibility == Opcodes.ACC_PRIVATE -> ownerClass == scopeClassOrPackage
|
jvmVisibility == Opcodes.ACC_PRIVATE -> ownerClass == scopeClassOrPackage
|
||||||
|
!withSuper && samePackage && jvmVisibility == 0 /* package only */ -> true
|
||||||
// JVM `protected`, unlike Kotlin `protected`, permits accesses from the same package,
|
// JVM `protected`, unlike Kotlin `protected`, permits accesses from the same package,
|
||||||
// provided the call is not across class loader boundaries.
|
// provided the call is not across class loader boundaries.
|
||||||
!withSuper && samePackage && !fromOtherClassLoader -> true
|
!withSuper && samePackage && !fromOtherClassLoader -> true
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
// TARGET_BACKEND: JVM
|
||||||
|
|
||||||
|
// FILE: SubClass.kt
|
||||||
|
|
||||||
|
class SubClass: BaseClass() {
|
||||||
|
inner class InnerClass {
|
||||||
|
fun foo() = super@SubClass.foo()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box() = SubClass().InnerClass().foo()
|
||||||
|
|
||||||
|
// FILE: BaseClass.java
|
||||||
|
public class BaseClass {
|
||||||
|
String foo() {
|
||||||
|
return "OK";
|
||||||
|
}
|
||||||
|
}
|
||||||
+6
@@ -5667,6 +5667,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/classes/kt508.kt");
|
runTest("compiler/testData/codegen/box/classes/kt508.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt53007.kt")
|
||||||
|
public void testKt53007() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/classes/kt53007.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("kt5347.kt")
|
@TestMetadata("kt5347.kt")
|
||||||
public void testKt5347() throws Exception {
|
public void testKt5347() throws Exception {
|
||||||
|
|||||||
+6
@@ -5781,6 +5781,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/classes/kt508.kt");
|
runTest("compiler/testData/codegen/box/classes/kt508.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt53007.kt")
|
||||||
|
public void testKt53007() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/classes/kt53007.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("kt5347.kt")
|
@TestMetadata("kt5347.kt")
|
||||||
public void testKt5347() throws Exception {
|
public void testKt5347() throws Exception {
|
||||||
|
|||||||
+5
@@ -4951,6 +4951,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/classes/kt508.kt");
|
runTest("compiler/testData/codegen/box/classes/kt508.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt53007.kt")
|
||||||
|
public void testKt53007() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/classes/kt53007.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt5347.kt")
|
@TestMetadata("kt5347.kt")
|
||||||
public void testKt5347() throws Exception {
|
public void testKt5347() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/classes/kt5347.kt");
|
runTest("compiler/testData/codegen/box/classes/kt5347.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user