From ddae8fd220ab376194e1827d908f6492274a9c5e Mon Sep 17 00:00:00 2001 From: Iulian Dragos Date: Tue, 25 Sep 2007 10:00:09 +0000 Subject: Fixed ticket #116 (protected accessor crashes c... Fixed ticket #116 (protected accessor crashes compiler). --- src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala') diff --git a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala index 7323529d94..26b4f9c72d 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala @@ -329,6 +329,9 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT * A special case arises for classes with explicit self-types. If the * self type is a Java class, and a protected accessor is needed, we issue * an error. If the self type is a Scala class, we don't add an accessor. + * An accessor is not needed if the access boundary is larger than the + * enclosing package, since that translates to 'public' on the host system. + * (as Java has no real package nesting). * * If the access happens inside a 'trait', access is more problematic since * the implementation code is moved to an '$class' class which does not @@ -339,7 +342,8 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT val res = /* settings.debug.value && */ ((sym hasFlag PROTECTED) && (!validCurrentOwner || !(currentOwner.enclClass.thisSym isSubClass sym.owner)) - && (enclPackage(sym.owner) != enclPackage(currentOwner))) + && (enclPackage(sym.owner) != enclPackage(currentOwner)) + && (enclPackage(sym.owner) == sym.accessBoundary(sym.owner))) if (res) { val host = hostForAccessorOf(sym, currentOwner.enclClass) -- cgit v1.2.3