summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Contexts.scala2
-rw-r--r--test/files/neg/t3934.check13
-rw-r--r--test/files/neg/t3934.scala23
3 files changed, 37 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
index 3e7f755b8e..7f182326dd 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
@@ -419,7 +419,7 @@ trait Contexts { self: Analyzer =>
if (!res)
lastAccessCheckDetails =
"\n Access to protected "+target+" not permitted because"+
- "\n prefix type "+pre.widen+" does not conform to"
+ "\n prefix type "+pre.widen+" does not conform to"+
"\n "+c.owner+c.owner.locationString+" where the access take place"
res
}
diff --git a/test/files/neg/t3934.check b/test/files/neg/t3934.check
new file mode 100644
index 0000000000..ebc6dfb876
--- /dev/null
+++ b/test/files/neg/t3934.check
@@ -0,0 +1,13 @@
+t3934.scala:15: error: method f2 in class J cannot be accessed in test.J
+ Access to protected method f2 not permitted because
+ enclosing class class S1 in package nest is not a subclass of
+ class J in package test where target is defined
+ def g2(x: J) = x.f2()
+ ^
+t3934.scala:20: error: method f2 in class J cannot be accessed in test.J
+ Access to protected method f2 not permitted because
+ prefix type test.J does not conform to
+ class S2 in package nest where the access take place
+ def g2(x: J) = x.f2()
+ ^
+two errors found
diff --git a/test/files/neg/t3934.scala b/test/files/neg/t3934.scala
new file mode 100644
index 0000000000..46e9088af3
--- /dev/null
+++ b/test/files/neg/t3934.scala
@@ -0,0 +1,23 @@
+package test {
+
+class J {
+ def f1(): Int = { return 5; }
+ protected def f2(): Int = { return 5; }
+}
+
+}
+
+package test {
+package nest {
+
+class S1 {
+ def g1(x: J) = x.f1()
+ def g2(x: J) = x.f2()
+}
+
+class S2 extends J {
+ def g1(x: J) = x.f1()
+ def g2(x: J) = x.f2()
+}
+
+}}