Skip to content

Commit 895598f

Browse files
authored
Merge pull request #14662 from vasilmkd/java-package-private-forwarders
Filter out static forwarders for Java package private methods
2 parents fb235fc + cf71532 commit 895598f

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

compiler/src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1388,7 +1388,7 @@ object SymDenotations {
13881388
final def accessBoundary(base: Symbol)(using Context): Symbol =
13891389
if (this.is(Private)) owner
13901390
else if (this.isAllOf(StaticProtected)) defn.RootClass
1391-
else if (privateWithin.exists && !ctx.phase.erasedTypes) privateWithin
1391+
else if (privateWithin.exists && (!ctx.phase.erasedTypes || this.is(JavaDefined))) privateWithin
13921392
else if (this.is(Protected)) base
13931393
else defn.RootClass
13941394

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
public static java.lang.String scalapackage.Foo.publicMethod()
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package javapackage;
2+
3+
public class Base_1 {
4+
int packagePrivateMethod() {
5+
return 42;
6+
}
7+
8+
public String publicMethod() {
9+
return "foo";
10+
}
11+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package scalapackage:
2+
object Foo extends javapackage.Base_1
3+
end scalapackage
4+
5+
object Test {
6+
def main(args: Array[String]): Unit = {
7+
println(
8+
Class.forName("scalapackage.Foo").getMethods
9+
.filter(m => (m.getModifiers & java.lang.reflect.Modifier.STATIC) != 0)
10+
.mkString("\n"))
11+
}
12+
}

0 commit comments

Comments
 (0)