Skip to content

Commit 3b8cab4

Browse files
vasilmkdsmarter
andcommitted
Filter out static forwarders for Java package private methods
Co-authored-by: Guillaume Martres <[email protected]>
1 parent e078e79 commit 3b8cab4

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
public static void MyClassValue.remove(java.lang.Class)
2+
public static java.lang.Object MyClassValue.get(java.lang.Class)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
object MyClassValue extends ClassValue[String] {
2+
override protected def computeValue(cls: Class[_]): String = ""
3+
}
4+
5+
object Test {
6+
def main(args: Array[String]): Unit = {
7+
println(
8+
Class.forName("MyClassValue").getMethods
9+
.filter(m => (m.getModifiers & java.lang.reflect.Modifier.STATIC) != 0)
10+
.mkString("\n"))
11+
}
12+
}

0 commit comments

Comments
 (0)