again: relax access boundry check for overriding protected java members. review by eugenevigdorchik.

git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@23714 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
rytz 2010-12-08 06:07:27 +00:00
parent fbc4ec61d3
commit fd557d8e31
11 changed files with 23 additions and 18 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -384,7 +384,7 @@ class Scaladoc extends ScalaMatchingTask {
/** This is forwarding method to circumvent bug #281 in Scala 2. Remove when
* bug has been corrected.
*/
override def getDirectoryScanner(baseDir: java.io.File) =
override protected def getDirectoryScanner(baseDir: java.io.File) =
super.getDirectoryScanner(baseDir)
/** Transforms a string name into a file relative to the provided base

View File

@ -329,9 +329,10 @@ abstract class RefChecks extends InfoTransform {
// todo: align accessibility implication checking with isAccessible in Contexts
val ob = other.accessBoundary(member.owner)
val mb = member.accessBoundary(member.owner)
def isOverrideAccessOK = member.isPublic || { // member is public, definitely same or relaxed access
(!other.isProtected || member.isProtected) && // if o is protected, so is m
(!isRootOrNone(ob) && ob.hasTransOwner(mb)) // m relaxes o's access boundary
def isOverrideAccessOK = member.isPublic || { // member is public, definitely same or relaxed access
(!other.isProtected || member.isProtected) && // if o is protected, so is m
((!isRootOrNone(ob) && ob.hasTransOwner(mb)) || // m relaxes o's access boundary
other.isJavaDefined) // overriding a protected java member, see #3946
}
if (!isOverrideAccessOK) {
overrideAccessError()

View File

@ -78,7 +78,7 @@ class Frame extends RichWindow {
override lazy val peer: JFrame with InterfaceMixin = new JFrame with InterfaceMixin with SuperMixin
protected trait SuperMixin extends JFrame {
override def processWindowEvent(e: java.awt.event.WindowEvent) {
override protected def processWindowEvent(e: java.awt.event.WindowEvent) {
super.processWindowEvent(e)
if (e.getID() == java.awt.event.WindowEvent.WINDOW_CLOSING)
closeOperation()

View File

@ -1,5 +0,0 @@
S_1.scala:3: error: overriding method m in class J of type ()Unit;
method m has weaker access privileges; it should be at least protected[p]
override protected def m { }
^
one error found

View File

@ -1,4 +0,0 @@
package p;
public class J {
protected void m() { return; }
}

View File

@ -1,4 +0,0 @@
package p
class S extends J {
override protected def m { }
}

View File

@ -0,0 +1,5 @@
package p;
public class A {
protected void f() {}
}

View File

@ -0,0 +1,12 @@
package q {
class B extends p.A {
override protected def f() { }
}
}
package p {
object T {
val a = new A()
a.f()
}
}