From 1c69dbcead1d4b1d5033d316d1c0468e46b310b3 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Sat, 15 Jun 2013 15:49:17 -0400 Subject: SI-7582 Only inline accessible calls to package-private Java code Two problems here. The inliner was using `isPrivate` / `isProtected` to determine access. The fallthrough considered things to be (bytecode) public. This is okay in practice for Scala code, which never emits package private code. Secondly, we must check accessibility of the called symbol *and* its owner. This case is tested in `run/t7582b`. This commit tightens the check for Java defined symbols: a) check the owner, and b) don't assume that `! isPrivate` is accessible. --- src/compiler/scala/tools/nsc/backend/opt/Inliners.scala | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/compiler') diff --git a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala index a6eedbd07e..56191cc981 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala @@ -679,9 +679,18 @@ abstract class Inliners extends SubComponent { } */ - def checkField(f: Symbol) = check(f, f.isPrivate && !canMakePublic(f)) - def checkSuper(n: Symbol) = check(n, n.isPrivate || !n.isClassConstructor) - def checkMethod(n: Symbol) = check(n, n.isPrivate) + + def isPrivateForInlining(sym: Symbol): Boolean = { + if (sym.isJavaDefined) { + def check(sym: Symbol) = !(sym.isPublic || sym.isProtected) + check(sym) || check(sym.owner) // SI-7582 Must check the enclosing class *and* the symbol for Java. + } + else sym.isPrivate // Scala never emits package-private bytecode + } + + def checkField(f: Symbol) = check(f, isPrivateForInlining(f) && !canMakePublic(f)) + def checkSuper(n: Symbol) = check(n, isPrivateForInlining(n) || !n.isClassConstructor) + def checkMethod(n: Symbol) = check(n, isPrivateForInlining(n)) def getAccess(i: Instruction) = i match { case CALL_METHOD(n, SuperCall(_)) => checkSuper(n) -- cgit v1.2.3