@@ -223,7 +223,7 @@ trait Checkable {
223223 * additional conditions holds:
224224 * - either A or B is effectively final
225225 * - neither A nor B is a trait (i.e. both are actual classes, not eligible for mixin)
226- * - both A and B are sealed/final, and every possible pairing of their children is irreconcilable
226+ * - either A or B is sealed/final, and every possible pairing of their children (or themselves) is irreconcilable
227227 *
228228 * The last two conditions of the last possibility (that the symbols are not of
229229 * classes being compiled in the current run) are because this currently runs too early,
@@ -241,15 +241,15 @@ trait Checkable {
241241 )
242242 // Are all children of these symbols pairwise irreconcilable?
243243 def allChildrenAreIrreconcilable (sym1 : Symbol , sym2 : Symbol ) = {
244- val sc1 = sym1.sealedChildren
245- val sc2 = sym2.sealedChildren
244+ val sc1 = if (isSealedOrFinal( sym1)) sym1 .sealedChildren else Set (sym1)
245+ val sc2 = if (isSealedOrFinal( sym2)) sym2 .sealedChildren else Set (sym2)
246246 sc1.forall(c1 => sc2.forall(c2 => areIrreconcilableAsParents(c1, c2)))
247247 }
248248 areUnrelatedClasses(sym1, sym2) && (
249249 isEffectivelyFinal(sym1) // initialization important
250250 || isEffectivelyFinal(sym2)
251251 || ! sym1.isTrait && ! sym2.isTrait
252- || isSealedOrFinal(sym1) && isSealedOrFinal(sym2) && allChildrenAreIrreconcilable(sym1, sym2) && (isRecheck || ! currentRun.compiles(sym1) && ! currentRun.compiles(sym2))
252+ || ( isSealedOrFinal(sym1) || isSealedOrFinal(sym2) ) && allChildrenAreIrreconcilable(sym1, sym2) && (isRecheck || ! currentRun.compiles(sym1) && ! currentRun.compiles(sym2))
253253 )
254254 }
255255 private def isSealedOrFinal (sym : Symbol ) = sym.isSealed || sym.isFinal
@@ -370,7 +370,7 @@ trait Checkable {
370370 def isSealedOrFinal (sym : Symbol ) = sym.isSealed || sym.isFinal
371371 val Xsym = X .typeSymbol
372372 val Psym = P .typeSymbol
373- if (isSealedOrFinal(Xsym ) && isSealedOrFinal(Psym ) && (currentRun.compiles(Xsym ) || currentRun.compiles(Psym ))) {
373+ if (( isSealedOrFinal(Xsym ) || isSealedOrFinal(Psym ) ) && (currentRun.compiles(Xsym ) || currentRun.compiles(Psym ))) {
374374 debuglog(s " deferred recheckFruitless( $X, $P) " )
375375 context.unit.addPostTyperCheck(() => recheckFruitless())
376376 }
0 commit comments