KT-53007 Fix accessibility checks when calling a protected member via super@Outer

This commit is contained in:
Pavel Mikhailovskii
2022-07-13 13:08:59 +02:00
parent 603d043abc
commit b26155dd9e
6 changed files with 42 additions and 1 deletions
@@ -91,8 +91,8 @@ internal class SyntheticAccessorLowering(val context: JvmBackendContext) : FileL
val scopeClassOrPackage = inlineScopeResolver.findContainer(currentScope!!.irElement) ?: return false
val samePackage = ownerClass.getPackageFragment().fqName == scopeClassOrPackage.getPackageFragment()?.fqName
return when {
jvmVisibility == 0 /* package only */ -> samePackage
jvmVisibility == Opcodes.ACC_PRIVATE -> ownerClass == scopeClassOrPackage
!withSuper && samePackage && jvmVisibility == 0 /* package only */ -> true
// JVM `protected`, unlike Kotlin `protected`, permits accesses from the same package,
// provided the call is not across class loader boundaries.
!withSuper && samePackage && !fromOtherClassLoader -> true