Skip to content

Commit cf21a07

Browse files
committed
Fix #15199: Exclude JavaDefined Modules from bridge generation.
JavaDefined modules are imaginary symbols that dotc uses to refer to static methods of Java classes. They have no reification, and therefore it makes no sense for them to participate in bridge generation.
1 parent 0c8e129 commit cf21a07

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

compiler/src/dotty/tools/dotc/transform/Bridges.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Bridges(root: ClassSymbol, thisPhase: DenotTransformer)(using Context) {
3737
override def parents = Array(root.superClass)
3838

3939
override def exclude(sym: Symbol) =
40-
!sym.isOneOf(MethodOrModule) || super.exclude(sym)
40+
!sym.isOneOf(MethodOrModule) || sym.isAllOf(Module | JavaDefined) || super.exclude(sym)
4141

4242
override def canBeHandledByParent(sym1: Symbol, sym2: Symbol, parent: Symbol): Boolean =
4343
OverridingPairs.isOverridingPair(sym1, sym2, parent.thisType)

tests/run/i15199/Child_1.java

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
public class Child_1 extends Parent_1 {
2+
public class Inner {
3+
}
4+
}

tests/run/i15199/Parent_1.java

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
public class Parent_1 {
2+
public class Inner {
3+
}
4+
}

tests/run/i15199/Test_2.scala

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class ScalaChild extends Child_1
2+
3+
@main def Test(): Unit =
4+
val methods = classOf[ScalaChild].getDeclaredMethods()
5+
assert(methods.length == 0, methods.mkString(", "))

0 commit comments

Comments
 (0)