Skip to content

Commit d31d775

Browse files
Fix #6152: dotc requires override to implement abstract java method
The reason is that bridges are allowed to participate in overriding relationships. This commit does the same scalac does, that is, prevent bridges from participation in such relationships.
1 parent 24946d8 commit d31d775

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

compiler/src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1141,7 +1141,7 @@ object SymDenotations {
11411141
* either as overrider or overridee.
11421142
*/
11431143
final def memberCanMatchInheritedSymbols(implicit ctx: Context): Boolean =
1144-
!isConstructor && !is(Private)
1144+
!isConstructor && !is(Private | Artifact)
11451145

11461146
/** The symbol, in class `inClass`, that is overridden by this denotation in class `siteClass`.*/
11471147
final def overriddenSymbol(inClass: ClassSymbol, siteClass: ClassSymbol = owner.asClass)(implicit ctx: Context): Symbol =

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ object ClassfileConstants {
341341
case JAVA_ACC_PRIVATE => Private
342342
case JAVA_ACC_PROTECTED => Protected
343343
case JAVA_ACC_FINAL => Final
344-
case JAVA_ACC_SYNTHETIC => Synthetic
344+
case JAVA_ACC_SYNTHETIC => Synthetic | Artifact
345345
case JAVA_ACC_STATIC => JavaStatic
346346
case JAVA_ACC_ABSTRACT => if (isClass) Abstract else Deferred
347347
case JAVA_ACC_INTERFACE => PureInterfaceCreationFlags | JavaDefined

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)