summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/ant/Scaladoc.scala2
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala5
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala8
-rw-r--r--src/swing/scala/swing/RichWindow.scala2
-rw-r--r--test/files/neg/t3946.check5
-rw-r--r--test/files/neg/t3946/J.java4
-rw-r--r--test/files/neg/t3946/S_1.scala4
7 files changed, 27 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/ant/Scaladoc.scala b/src/compiler/scala/tools/ant/Scaladoc.scala
index 3d96b959f5..427846fa33 100644
--- a/src/compiler/scala/tools/ant/Scaladoc.scala
+++ b/src/compiler/scala/tools/ant/Scaladoc.scala
@@ -385,7 +385,7 @@ class Scaladoc extends MatchingTask {
/** This is forwarding method to circumvent bug #281 in Scala 2. Remove when
* bug has been corrected.
*/
- override protected def getDirectoryScanner(baseDir: java.io.File) =
+ override def getDirectoryScanner(baseDir: java.io.File) =
super.getDirectoryScanner(baseDir)
/** Transforms a string name into a file relative to the provided base
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
index 109de180a4..b3eced4402 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
@@ -1323,6 +1323,11 @@ abstract class ClassfileParser {
// apparently occurs when processing v45.3 bytecode.
if (sym.toplevelClass != NoSymbol)
sym.privateWithin = sym.toplevelClass.owner
+
+ // protected in java means package protected. #3946
+ if ((jflags & JAVA_ACC_PROTECTED) != 0)
+ if (sym.toplevelClass != NoSymbol)
+ sym.privateWithin = sym.toplevelClass.owner
}
@inline final private def isPrivate(flags: Int) =
diff --git a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala
index 09a0f4cfe4..c1a44dba93 100644
--- a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala
@@ -417,13 +417,19 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT
def accessibleThroughSubclassing =
validCurrentOwner && clazz.thisSym.isSubClass(sym.owner) && !clazz.isTrait
+ def packageAccessBoundry(sym: Symbol) = {
+ val b = sym.accessBoundary(sym.owner)
+ if (b.isPackageClass) b
+ else b.enclosingPackageClass
+ }
+
val isCandidate = (
sym.isProtected
&& sym.isJavaDefined
&& !sym.definedInPackage
&& !accessibleThroughSubclassing
&& (sym.owner.enclosingPackageClass != currentOwner.enclosingPackageClass)
- && (sym.owner.enclosingPackageClass == sym.accessBoundary(sym.owner).enclosingPackageClass)
+ && (sym.owner.enclosingPackageClass == packageAccessBoundry(sym))
)
val host = hostForAccessorOf(sym, clazz)
def isSelfType = (host.thisSym != host) && {
diff --git a/src/swing/scala/swing/RichWindow.scala b/src/swing/scala/swing/RichWindow.scala
index 10e396247e..dcad382a33 100644
--- a/src/swing/scala/swing/RichWindow.scala
+++ b/src/swing/scala/swing/RichWindow.scala
@@ -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 protected def processWindowEvent(e: java.awt.event.WindowEvent) {
+ override def processWindowEvent(e: java.awt.event.WindowEvent) {
super.processWindowEvent(e)
if (e.getID() == java.awt.event.WindowEvent.WINDOW_CLOSING)
closeOperation()
diff --git a/test/files/neg/t3946.check b/test/files/neg/t3946.check
new file mode 100644
index 0000000000..6379b50dba
--- /dev/null
+++ b/test/files/neg/t3946.check
@@ -0,0 +1,5 @@
+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
diff --git a/test/files/neg/t3946/J.java b/test/files/neg/t3946/J.java
new file mode 100644
index 0000000000..189b8e1d23
--- /dev/null
+++ b/test/files/neg/t3946/J.java
@@ -0,0 +1,4 @@
+package p;
+public class J {
+ protected void m() { return; }
+}
diff --git a/test/files/neg/t3946/S_1.scala b/test/files/neg/t3946/S_1.scala
new file mode 100644
index 0000000000..2c52094701
--- /dev/null
+++ b/test/files/neg/t3946/S_1.scala
@@ -0,0 +1,4 @@
+package p
+class S extends J {
+ override protected def m { }
+}