Skip to content

Fix #15199: Exclude JavaDefined Modules from bridge generation. #15499

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

Merged
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/transform/Bridges.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Bridges(root: ClassSymbol, thisPhase: DenotTransformer)(using Context) {
override def parents = Array(root.superClass)

override def exclude(sym: Symbol) =
!sym.isOneOf(MethodOrModule) || super.exclude(sym)
!sym.isOneOf(MethodOrModule) || sym.isAllOf(Module | JavaDefined) || super.exclude(sym)

override def canBeHandledByParent(sym1: Symbol, sym2: Symbol, parent: Symbol): Boolean =
OverridingPairs.isOverridingPair(sym1, sym2, parent.thisType)
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Checking.scala
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ object Checking {
fail("Traits cannot have secondary constructors" + addendum)
checkApplicable(Inline, sym.isTerm && !sym.isOneOf(Mutable | Module))
checkApplicable(Lazy, !sym.isOneOf(Method | Mutable))
if (sym.isType && !sym.is(Deferred))
if (sym.isType && !sym.isOneOf(Deferred | JavaDefined))
for (cls <- sym.allOverriddenSymbols.filter(_.isClass)) {
fail(CannotHaveSameNameAs(sym, cls, CannotHaveSameNameAs.CannotBeOverridden))
sym.setFlag(Private) // break the overriding relationship by making sym Private
Expand Down
4 changes: 4 additions & 0 deletions tests/run/i15199/Child_1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
public class Child_1 extends Parent_1 {
public class Inner {
}
}
4 changes: 4 additions & 0 deletions tests/run/i15199/Parent_1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
public class Parent_1 {
public class Inner {
}
}
5 changes: 5 additions & 0 deletions tests/run/i15199/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class ScalaChild extends Child_1

@main def Test(): Unit =
val methods = classOf[ScalaChild].getDeclaredMethods()
assert(methods.length == 0, methods.mkString(", "))