diff options
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/Erasure.scala | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index e036035397..2f2142027f 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -1050,20 +1050,18 @@ abstract class Erasure extends AddInterfaces } } - def isAccessible(sym: Symbol) = localTyper.context.isAccessible(sym, sym.owner.thisType) - if (!isAccessible(owner) && qual.tpe != null) { + def isJvmAccessible(sym: Symbol) = (sym.isClass && !sym.isJavaDefined) || localTyper.context.isAccessible(sym, sym.owner.thisType) + if (!isJvmAccessible(owner) && qual.tpe != null) { qual match { case Super(_, _) => - // Insert a cast here at your peril -- see SI-5162. Bail out if the target method is defined in - // Java, otherwise, we'd get an IllegalAccessError at runtime. If the target method is defined in - // Scala, however, we should have access. - if (owner.isJavaDefined) unit.error(tree.pos, s"Unable to access ${tree.symbol.fullLocationString} with a super reference.") + // Insert a cast here at your peril -- see SI-5162. + unit.error(tree.pos, s"Unable to access ${tree.symbol.fullLocationString} with a super reference.") tree case _ => // Todo: Figure out how qual.tpe could be null in the check above (it does appear in build where SwingWorker.this // has a null type). val qualSym = qual.tpe.widen.typeSymbol - if (isAccessible(qualSym) && !qualSym.isPackageClass && !qualSym.isPackageObjectClass) { + if (isJvmAccessible(qualSym) && !qualSym.isPackageClass && !qualSym.isPackageObjectClass) { // insert cast to prevent illegal access error (see #4283) // util.trace("insert erasure cast ") (*/ treeCopy.Select(tree, gen.mkAttributedCast(qual, qual.tpe.widen), name) //) |