Skip to content

Commit

Permalink
Filter out static forwarders for Java package private methods
Browse files Browse the repository at this point in the history
Co-authored-by: Guillaume Martres <[email protected]>
  • Loading branch information
vasilmkd and smarter committed Mar 10, 2022
1 parent e078e79 commit 3b8cab4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
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
2 changes: 2 additions & 0 deletions tests/run/forwarder-java-package-private.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
public static void MyClassValue.remove(java.lang.Class)
public static java.lang.Object MyClassValue.get(java.lang.Class)
12 changes: 12 additions & 0 deletions tests/run/forwarder-java-package-private.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
object MyClassValue extends ClassValue[String] {
override protected def computeValue(cls: Class[_]): String = ""
}

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

0 comments on commit 3b8cab4

Please sign in to comment.