@@ -260,7 +260,7 @@ object RefChecks {
260260 def overrideAccessError () = {
261261 ctx.log(i " member: ${member.showLocated} ${member.flagsString}" ) // DEBUG
262262 ctx.log(i " other: ${other.showLocated} ${other.flagsString}" ) // DEBUG
263- val otherAccess = (other.flags & AccessFlags ).toString
263+ val otherAccess = (other.flags & AccessFlags ).flagsString
264264 overrideError(" has weaker access privileges; it should be " +
265265 (if (otherAccess == " " ) " public" else " at least " + otherAccess))
266266 }
@@ -325,13 +325,14 @@ object RefChecks {
325325 // todo: align accessibility implication checking with isAccessible in Contexts
326326 val ob = other.accessBoundary(member.owner)
327327 val mb = member.accessBoundary(member.owner)
328- def isOverrideAccessOK = (
329- (member.flags & AccessFlags ).isEmpty // member is public
330- || // - or -
331- (! other.is(Protected ) || member.is(Protected )) && // if o is protected, so is m, and
332- (ob.isContainedIn(mb) || other.isAllOf(JavaProtected )) // m relaxes o's access boundary,
333- // or o is Java defined and protected (see #3946)
334- )
328+ def isOverrideAccessOK =
329+ (member.flags & AccessFlags ).isEmpty
330+ && ! member.privateWithin.exists // member is public, or
331+ || (! other.is(Protected ) || member.is(Protected ))
332+ // if o is protected, so is m, and
333+ && (ob.isContainedIn(mb) || other.isAllOf(JavaProtected ))
334+ // m relaxes o's access boundary,
335+ // or o is Java defined and protected (see #3946)
335336 if (! isOverrideAccessOK)
336337 overrideAccessError()
337338 else if (other.isClass)
0 commit comments