Skip to content

Commit 9dbade3

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 8ffed08 commit 9dbade3

File tree

4 files changed

+4
-3
lines changed

4 files changed

+4
-3
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,7 @@ object Flags {
731731
final val SyntheticTypeParam: FlagConjunction = allOf(Synthetic, TypeParam)
732732
final val SyntheticCase: FlagConjunction = allOf(Synthetic, Case)
733733
final val SyntheticOpaque: FlagConjunction = allOf(Synthetic, Opaque)
734+
final val BridgeArtifact: FlagConjunction = allOf(Bridge, Artifact)
734735

735736
implicit def conjToFlagSet(conj: FlagConjunction): FlagSet =
736737
FlagSet(conj.bits)

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) && !is(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
@@ -375,6 +375,6 @@ object ClassfileConstants {
375375
override def baseFlags(jflags: Int) = if ((jflags & JAVA_ACC_FINAL) == 0) Mutable else EmptyFlags
376376
}
377377
val methodTranslation: FlagTranslation = new FlagTranslation {
378-
override def baseFlags(jflags: Int) = if ((jflags & JAVA_ACC_BRIDGE) != 0) Bridge else EmptyFlags
378+
override def baseFlags(jflags: Int) = if ((jflags & JAVA_ACC_BRIDGE) != 0) (BridgeArtifact) else EmptyFlags
379379
}
380380
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ object OverridingPairs {
4040
* relative to <base>.this do
4141
*/
4242
protected def matches(sym1: Symbol, sym2: Symbol): Boolean =
43-
sym1.isType || self.memberInfo(sym1).matches(self.memberInfo(sym2))
43+
sym1.isType || (!exclude(sym2) && self.memberInfo(sym1).matches(self.memberInfo(sym2)))
4444

4545
/** The symbols that can take part in an overriding pair */
4646
private val decls = {

0 commit comments

Comments
 (0)