diff options
author | amin <nada.amin@epfl.ch> | 2012-09-11 15:09:03 +0200 |
---|---|---|
committer | amin <nada.amin@epfl.ch> | 2012-09-13 21:13:30 +0200 |
commit | e498fac7fdbda3187a2a4fffcdf7fa4f9ddb7ac8 (patch) | |
tree | 869c6a61906d00833e9c1093e221f40f2681b8e3 /src | |
parent | 76d4e9a8071f9e102106696664376b7f70622582 (diff) | |
download | scala-e498fac7fdbda3187a2a4fffcdf7fa4f9ddb7ac8.tar.gz scala-e498fac7fdbda3187a2a4fffcdf7fa4f9ddb7ac8.tar.bz2 scala-e498fac7fdbda3187a2a4fffcdf7fa4f9ddb7ac8.zip |
Fix for SI-6245 with workaround for SI-2296.
protected/super accessor issue: Don't subvert the creation of the
standard protected accessor with the java interop accessor. For
SI-2296, the compiler emits an error instead of causing an illegal
access error at runtime.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala index 63050bc032..981ba10183 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala @@ -287,16 +287,18 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT // FIXME - this should be unified with needsProtectedAccessor, but some // subtlety which presently eludes me is foiling my attempts. val shouldEnsureAccessor = ( - currentClass.isTrait + currentClass.isTrait && sym.isProtected && sym.enclClass != currentClass && !sym.owner.isTrait && (sym.owner.enclosingPackageClass != currentClass.enclosingPackageClass) - && (qual.symbol.info.member(sym.name) ne NoSymbol)) + && (qual.symbol.info.member(sym.name) ne NoSymbol) + && !needsProtectedAccessor(sym, tree.pos)) if (shouldEnsureAccessor) { log("Ensuring accessor for call to protected " + sym.fullLocationString + " from " + currentClass) ensureAccessor(sel) - } else + } + else mayNeedProtectedAccessor(sel, EmptyTree.asList, false) } @@ -525,7 +527,14 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT ) true } - isCandidate && !host.isPackageClass && !isSelfType + def isJavaProtected = host.isTrait && sym.isJavaDefined && { + restrictionError(pos, unit, + s"""|$clazz accesses protected $sym inside a concrete trait method. + |Add an accessor in a class extending ${sym.enclClass} as a workaround.""".stripMargin + ) + true + } + isCandidate && !host.isPackageClass && !isSelfType && !isJavaProtected } /** Return the innermost enclosing class C of referencingClass for which either |