Skip to content

Java methods can be overridden with weaker access privilege #11881

@lrytz

Description

@lrytz

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixed in Scala 3This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)java interop

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions