diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala index 05a496cdce..7ae2ce7bb1 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala @@ -395,8 +395,13 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT * classes, this has to be signaled as error. */ private def needsProtectedAccessor(sym: Symbol, pos: Position): Boolean = { + def errorRestriction(msg: String) { + unit.error(pos, "Implementation restriction: " + msg) + } + val res = /* settings.debug.value && */ ((sym hasFlag PROTECTED) + && !sym.owner.isPackageClass && (!validCurrentOwner || !(currentOwner.enclClass.thisSym isSubClass sym.owner)) && (enclPackage(sym.owner) != enclPackage(currentOwner)) && (enclPackage(sym.owner) == enclPackage(sym.accessBoundary(sym.owner)))) @@ -405,8 +410,8 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT val host = hostForAccessorOf(sym, currentOwner.enclClass) if (host.thisSym != host) { if (host.thisSym.tpe.typeSymbol.hasFlag(JAVA)) - unit.error(pos, "Implementation restriction: " + currentOwner.enclClass + " accesses protected " - + sym + " from self type " + host.thisSym.tpe) + errorRestriction(currentOwner.enclClass + " accesses protected " + sym + + " from self type " + host.thisSym.tpe) false } else res } else res |