diff --git a/community-build/community-projects/stdLib213 b/community-build/community-projects/stdLib213 index 1886950613d8..d175ff3e32cc 160000 --- a/community-build/community-projects/stdLib213 +++ b/community-build/community-projects/stdLib213 @@ -1 +1 @@ -Subproject commit 1886950613d85af824435b2c072e9eedb12d6851 +Subproject commit d175ff3e32ccf033020925cb427d0f5dd7a8a55d diff --git a/compiler/src/dotty/tools/dotc/typer/RefChecks.scala b/compiler/src/dotty/tools/dotc/typer/RefChecks.scala index 750bc7499b50..b65942013cb3 100644 --- a/compiler/src/dotty/tools/dotc/typer/RefChecks.scala +++ b/compiler/src/dotty/tools/dotc/typer/RefChecks.scala @@ -260,7 +260,7 @@ object RefChecks { def overrideAccessError() = { ctx.log(i"member: ${member.showLocated} ${member.flagsString}") // DEBUG ctx.log(i"other: ${other.showLocated} ${other.flagsString}") // DEBUG - val otherAccess = (other.flags & AccessFlags).toString + val otherAccess = (other.flags & AccessFlags).flagsString overrideError("has weaker access privileges; it should be " + (if (otherAccess == "") "public" else "at least " + otherAccess)) } @@ -325,13 +325,14 @@ object RefChecks { // todo: align accessibility implication checking with isAccessible in Contexts val ob = other.accessBoundary(member.owner) val mb = member.accessBoundary(member.owner) - def isOverrideAccessOK = ( - (member.flags & AccessFlags).isEmpty // member is public - || // - or - - (!other.is(Protected) || member.is(Protected)) && // if o is protected, so is m, and - (ob.isContainedIn(mb) || other.isAllOf(JavaProtected)) // m relaxes o's access boundary, - // or o is Java defined and protected (see #3946) - ) + def isOverrideAccessOK = + (member.flags & AccessFlags).isEmpty + && !member.privateWithin.exists // member is public, or + || (!other.is(Protected) || member.is(Protected)) + // if o is protected, so is m, and + && (ob.isContainedIn(mb) || other.isAllOf(JavaProtected)) + // m relaxes o's access boundary, + // or o is Java defined and protected (see #3946) if (!isOverrideAccessOK) overrideAccessError() else if (other.isClass) diff --git a/tests/neg/i8005.scala b/tests/neg/i8005.scala new file mode 100644 index 000000000000..1e11762509ea --- /dev/null +++ b/tests/neg/i8005.scala @@ -0,0 +1,12 @@ +package nio +abstract class Buffer { + val isReadOnly: Boolean + def foo(): Unit + def bar(): Unit +} + +class ByteBuffer extends Buffer { // error: ByteBufer needs to be abstract since `bar` is not defined + private[nio] val isReadOnly: Boolean = false // error + protected def foo(): Unit = () // error + private def bar(): Unit = () +}