@@ -219,19 +219,23 @@ object RefChecks {
219219 false
220220 precedesIn(parent.asClass.baseClasses)
221221
222- // We can exclude pairs safely from checking only under three additional conditions
223- // - their signatures also match in the parent class.
224- // See neg/i12828.scala for an example where this matters.
225- // - They overriding/overridden appear in linearization order.
226- // See neg/i5094.scala for an example where this matters.
227- // - The overridden symbol is not `abstract override`. For such symbols
228- // we need a more extensive test since the virtual super chain depends
229- // on the precise linearization order, which might be different for the
230- // subclass. See neg/i14415.scala.
222+ /** We can exclude pairs safely from checking only under three additional conditions
223+ * - their signatures also match in the parent class.
224+ * See neg/i12828.scala for an example where this matters.
225+ * - They overriding/overridden appear in linearization order.
226+ * See neg/i5094.scala for an example where this matters.
227+ * - They overriding/overridden appear in linearization order,
228+ * or the parent is a Java class (because linearization does not apply to java classes).
229+ * See neg/i5094.scala and pos/i18654.scala for examples where this matters.
230+ * - The overridden symbol is not `abstract override`. For such symbols
231+ * we need a more extensive test since the virtual super chain depends
232+ * on the precise linearization order, which might be different for the
233+ * subclass. See neg/i14415.scala.
234+ */
231235 override def canBeHandledByParent (sym1 : Symbol , sym2 : Symbol , parent : Symbol ): Boolean =
232236 isOverridingPair(sym1, sym2, parent.thisType)
233237 .showing(i " already handled ${sym1.showLocated}: ${sym1.asSeenFrom(parent.thisType).signature}, ${sym2.showLocated}: ${sym2.asSeenFrom(parent.thisType).signature} = $result" , refcheck)
234- && inLinearizationOrder(sym1, sym2, parent)
238+ && ( inLinearizationOrder(sym1, sym2, parent) || parent.is( JavaDefined ) )
235239 && ! sym2.is(AbsOverride )
236240
237241 // Checks the subtype relationship tp1 <:< tp2.
0 commit comments