Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java methods can be overridden with weaker access privilege #11881

Open
lrytz opened this issue Feb 10, 2020 · 0 comments
Open

Java methods can be overridden with weaker access privilege #11881

lrytz opened this issue Feb 10, 2020 · 0 comments

Comments

@lrytz
Copy link
Member

@lrytz lrytz commented Feb 10, 2020

Found by doti in scala/scala#8697 (comment)

$> cat A.java
package p;
public abstract class A {
  public abstract String s(int i);
}

$> cat Test.scala
package p
class C extends A {
  private[p] def s(i: Int) = ""
}

$> scalac Test.scala A.java

$> dotc Test.scala A.java
-- Error: Test.scala:3:17 ------------------------------------------------------
3 |  private[p] def s(i: Int) = ""
  |                 ^
  |error overriding method s in class A of type (i: Int): String;
  |  method s of type (i: Int): String has weaker access privileges; it should be public
1 error found
@lrytz lrytz added the java interop label Feb 10, 2020
@lrytz lrytz added this to the Backlog milestone Feb 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.