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