private method shadows directly inherited public method #8143
Comments
|
Imported From: https://issues.scala-lang.org/browse/SI-8143?orig=1 |
|
@retronym said (edited on Jan 12, 2014 12:16:32 PM UTC): tail sandbox/{Test,Sub}.java
==> sandbox/Test.java <==
class Test {
public int foo() { return 0; }
}
==> sandbox/Sub.java <==
class Sub extends Test {
private int foo() { return 0; }
}
/code/scala javac sandbox/{Test,Sub}.java
sandbox/Sub.java:2: foo() in Sub cannot override foo() in Test; attempting to assign weaker access privileges; was public
private int foo() { return 0; }
^
1 error |
|
@paulp said: class A { def f = 5 }
class B extends A { private[B] def f = 10 }Not sure how that can be acceptable if straight private isn't. |
|
@retronym said: Seems like every call to scala> object O { trait T { private[O] def foo = 0 } }
defined module O
scala> val foo = typeOf[O.T].member(newTermName("foo"))
foo: $r.intp.global.Symbol = method foo
scala> foo.isPrivate
res0: Boolean = false
scala> foo.privateWithin
res1: $r.intp.global.Symbol = object O// RefChecks
if (member.isPrivate) // (1.1)
overrideError("has weaker access privileges; it should not be private")
member.privateWithin |
|
@retronym said: |
|
@retronym said: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This does not compile in 2.10, but does in master.
I think it regressed in e609f1f20b . The test case run/private-override.scala looks wrong - class Other is supposed to be in some package other than p2 to test what it is intending to test. I believe that bug is legit, just the test case is wrong, but also that it is the change which accompanied it which caused the bug being reported here.
The text was updated successfully, but these errors were encountered: