Skip to content

Commit 3713b75

Browse files
Fix #6152: Dotty tries to override Java bridge methods
Dotty overrides Java bridge methods when the user intends to override the method for which the bridge was generated. This commit forbids Dotty to override bridge methods altogether.
1 parent 24946d8 commit 3713b75

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ class ClassfileParser(
210210
if (method) Flags.Method | methodTranslation.flags(jflags)
211211
else fieldTranslation.flags(jflags)
212212
val name = pool.getName(in.nextChar)
213-
if (!(sflags is Flags.Private) || name == nme.CONSTRUCTOR) {
213+
if (!(sflags.is(Flags.Private) || sflags.is(Flags.Bridge)) || name == nme.CONSTRUCTOR) {
214214
val member = ctx.newSymbol(
215215
getOwner(jflags), name, sflags, memberCompleter, coord = start)
216216
getScope(jflags).enter(member)

tests/pos/i6152/A_1.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
abstract class A {
2+
public abstract Object f();
3+
4+
public static abstract class B extends A {
5+
@Override
6+
public abstract String f();
7+
}
8+
}

tests/pos/i6152/Test_2.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class C extends A.B {
2+
def f() = "hello"
3+
}
4+
5+
object Main extends App {
6+
val c: A = new C
7+
println(c.f())
8+
}

0 commit comments

Comments
 (0)