Skip to content

Commit 2b368c9

Browse files
committed
Ignore override errors in EqClass
These clash with final members in Any, but that's OK.
1 parent ae5dd91 commit 2b368c9

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/dotty/tools/dotc/typer/RefChecks.scala

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ object RefChecks {
300300
overrideError("cannot be used here - class definitions cannot be overridden")
301301
} else if (!other.is(Deferred) && member.isClass) {
302302
overrideError("cannot be used here - classes can only override abstract types")
303-
} else if (other.isEffectivelyFinal) { // (1.2)
303+
} else if (other.isEffectivelyFinal && !isIgnorable(member)) { // (1.2)
304304
overrideError(i"cannot override final member ${other.showLocated}")
305305
} else if (!other.is(Deferred) &&
306306
!isDefaultGetter(other.name) &&
@@ -314,7 +314,7 @@ object RefChecks {
314314
clazz + " inherits conflicting members:\n "
315315
+ infoStringWithLocation(other) + " and\n " + infoStringWithLocation(member)
316316
+ "\n(Note: this can be resolved by declaring an override in " + clazz + ".)")
317-
else
317+
else if (!isIgnorable(member))
318318
overrideError("needs `override' modifier")
319319
} else if (other.is(AbsOverride) && other.isIncompleteIn(clazz) && !member.is(AbsOverride)) {
320320
overrideError("needs `abstract override' modifiers")
@@ -640,6 +640,13 @@ object RefChecks {
640640
}
641641
}
642642

643+
/** Ignore `==' entries in EqClass; they clash with `final` entries in `Any` */
644+
private def isIgnorable(sym: Symbol)(implicit ctx: Context) = {
645+
val res = sym.owner == defn.EqClassClass
646+
if (!res) println(i"not ignorable: ${sym.owner} / ${defn.EqClassClass}")
647+
res
648+
}
649+
643650
// Note: if a symbol has both @deprecated and @migration annotations and both
644651
// warnings are enabled, only the first one checked here will be emitted.
645652
// I assume that's a consequence of some code trying to avoid noise by suppressing

0 commit comments

Comments
 (0)