@@ -2497,9 +2497,15 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
2497
2497
def provablyDisjoint (tp1 : Type , tp2 : Type )(using Context ): Boolean = trace(i " provable disjoint $tp1, $tp2" , matchTypes) {
2498
2498
// println(s"provablyDisjoint(${tp1.show}, ${tp2.show})")
2499
2499
2500
- def isEnumValueOrModule (ref : TermRef ): Boolean =
2500
+ def isEnumValue (ref : TermRef ): Boolean =
2501
2501
val sym = ref.termSymbol
2502
- sym.isAllOf(EnumCase , butNot= JavaDefined ) || sym.is(Module )
2502
+ sym.isAllOf(EnumCase , butNot= JavaDefined )
2503
+
2504
+ def isEnumValueOrModule (ref : TermRef ): Boolean =
2505
+ isEnumValue(ref) || ref.termSymbol.is(Module ) || (ref.info match {
2506
+ case tp : TermRef => isEnumValueOrModule(tp)
2507
+ case _ => false
2508
+ })
2503
2509
2504
2510
/** Can we enumerate all instantiations of this type? */
2505
2511
def isClosedSum (tp : Symbol ): Boolean =
@@ -2608,11 +2614,10 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
2608
2614
provablyDisjoint(tp1, gadtBounds(tp2.symbol).hi) || provablyDisjoint(tp1, tp2.superType)
2609
2615
case (tp1 : TermRef , tp2 : TermRef ) if isEnumValueOrModule(tp1) && isEnumValueOrModule(tp2) =>
2610
2616
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
2617
+ case (tp1 : TermRef , _) if isEnumValue(tp1) =>
2618
+ false
2619
+ case (_, tp2 : TermRef ) if isEnumValue(tp2) =>
2620
+ false
2616
2621
case (tp1 : Type , tp2 : Type ) if defn.isTupleType(tp1) =>
2617
2622
provablyDisjoint(tp1.toNestedPairs, tp2)
2618
2623
case (tp1 : Type , tp2 : Type ) if defn.isTupleType(tp2) =>
0 commit comments