@@ -877,7 +877,7 @@ object SymDenotations {
877877 * As a side effect, drop Local flags of members that are not accessed via the ThisType
878878 * of their owner.
879879 */
880- final def isAccessibleFrom (pre : Type , superAccess : Boolean = false , whyNot : StringBuffer | Null = null )(using Context ): Boolean = {
880+ final def isAccessibleFrom (pre : Type , superAccess : Boolean = false )(using Context ): Boolean = {
881881
882882 /** Are we inside definition of `boundary`?
883883 * If this symbol is Java defined, package structure is interpreted to be flat.
@@ -906,26 +906,13 @@ object SymDenotations {
906906
907907 /** Is protected access to target symbol permitted? */
908908 def isProtectedAccessOK : Boolean =
909- inline def fail (str : String ): false =
910- if whyNot != null then whyNot.nn.append(str)
911- false
912909 val cls = owner.enclosingSubClass
913910 if ! cls.exists then
914- if pre.termSymbol.isPackageObject && accessWithin(pre.termSymbol.owner) then
915- true
916- else
917- val encl = if ctx.owner.isConstructor then ctx.owner.enclosingClass.owner.enclosingClass else ctx.owner.enclosingClass
918- val location = if owner.is(Final ) then owner.showLocated else owner.showLocated + " or one of its subclasses"
919- fail(i """
920- | Protected $this can only be accessed from $location. """ )
921- else if isType || pre.derivesFrom(cls) || isConstructor || owner.is(ModuleClass ) then
911+ pre.termSymbol.isPackageObject && accessWithin(pre.termSymbol.owner)
912+ else
922913 // allow accesses to types from arbitrary subclasses fixes #4737
923914 // don't perform this check for static members
924- true
925- else
926- val location = if cls.is(Final ) then cls.showLocated else cls.showLocated + " or one of its subclasses"
927- fail(i """
928- | Protected $this can only be accessed from $location. """ )
915+ isType || pre.derivesFrom(cls) || isConstructor || owner.is(ModuleClass )
929916 end isProtectedAccessOK
930917
931918 if pre eq NoPrefix then true
0 commit comments