@@ -2494,7 +2494,12 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
2494
2494
2495
2495
def isEnumValueOrModule (ref : TermRef ): Boolean =
2496
2496
val sym = ref.termSymbol
2497
- sym.isAllOf(EnumCase , butNot= JavaDefined ) || sym.is(Module )
2497
+ val isEnumValue = sym.isAllOf(EnumCase , butNot= JavaDefined )
2498
+ val isModule = sym.is(Module )
2499
+ isEnumValue || isModule || (ref.info match {
2500
+ case tp : TermRef => isEnumValueOrModule(tp)
2501
+ case _ => false
2502
+ })
2498
2503
2499
2504
/** Can we enumerate all instantiations of this type? */
2500
2505
def isClosedSum (tp : Symbol ): Boolean =
@@ -2603,11 +2608,10 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
2603
2608
provablyDisjoint(tp1, gadtBounds(tp2.symbol).hi) || provablyDisjoint(tp1, tp2.superType)
2604
2609
case (tp1 : TermRef , tp2 : TermRef ) if isEnumValueOrModule(tp1) && isEnumValueOrModule(tp2) =>
2605
2610
tp1.termSymbol != tp2.termSymbol
2606
- case (tp1 : TermRef , tp2 : TypeRef ) if isEnumValueOrModule(tp1) && ! tp1.classSymbols.exists(_.derivesFrom(tp2.classSymbol)) =>
2607
- // Note: enum values may have multiple parents
2608
- true
2609
- case (tp1 : TypeRef , tp2 : TermRef ) if isEnumValueOrModule(tp2) && ! tp2.classSymbols.exists(_.derivesFrom(tp1.classSymbol)) =>
2610
- true
2611
+ case (tp1 : TermRef , tp2 : TypeRef ) if isEnumValueOrModule(tp1) && tp2.symbol.isClass =>
2612
+ ! isSubType(tp1, tp2)
2613
+ case (tp1 : TypeRef , tp2 : TermRef ) if isEnumValueOrModule(tp2) && tp1.symbol.isClass =>
2614
+ ! isSubType(tp2, tp1)
2611
2615
case (tp1 : Type , tp2 : Type ) if defn.isTupleType(tp1) =>
2612
2616
provablyDisjoint(tp1.toNestedPairs, tp2)
2613
2617
case (tp1 : Type , tp2 : Type ) if defn.isTupleType(tp2) =>
0 commit comments