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

Filter out static forwarders for Java package private methods #14662

Merged
merged 1 commit into from
Mar 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1388,7 +1388,7 @@ object SymDenotations {
final def accessBoundary(base: Symbol)(using Context): Symbol =
if (this.is(Private)) owner
else if (this.isAllOf(StaticProtected)) defn.RootClass
else if (privateWithin.exists && !ctx.phase.erasedTypes) privateWithin
else if (privateWithin.exists && (!ctx.phase.erasedTypes || this.is(JavaDefined))) privateWithin
else if (this.is(Protected)) base
else defn.RootClass

Expand Down
1 change: 1 addition & 0 deletions tests/run/forwarder-java-package-private.check
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
public static java.lang.String scalapackage.Foo.publicMethod()
11 changes: 11 additions & 0 deletions tests/run/forwarder-java-package-private/Base_1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package javapackage;

public class Base_1 {
int packagePrivateMethod() {
return 42;
}

public String publicMethod() {
return "foo";
}
}
12 changes: 12 additions & 0 deletions tests/run/forwarder-java-package-private/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package scalapackage:
object Foo extends javapackage.Base_1
end scalapackage

object Test {
def main(args: Array[String]): Unit = {
println(
Class.forName("scalapackage.Foo").getMethods
.filter(m => (m.getModifiers & java.lang.reflect.Modifier.STATIC) != 0)
.mkString("\n"))
}
}