@@ -2497,9 +2497,15 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
24972497 def provablyDisjoint (tp1 : Type , tp2 : Type )(using Context ): Boolean = trace(i " provable disjoint $tp1, $tp2" , matchTypes) {
24982498 // println(s"provablyDisjoint(${tp1.show}, ${tp2.show})")
24992499
2500- def isEnumValueOrModule (ref : TermRef ): Boolean =
2500+ def isEnumValue (ref : TermRef ): Boolean =
25012501 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+ })
25032509
25042510 /** Can we enumerate all instantiations of this type? */
25052511 def isClosedSum (tp : Symbol ): Boolean =
@@ -2608,11 +2614,10 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
26082614 provablyDisjoint(tp1, gadtBounds(tp2.symbol).hi) || provablyDisjoint(tp1, tp2.superType)
26092615 case (tp1 : TermRef , tp2 : TermRef ) if isEnumValueOrModule(tp1) && isEnumValueOrModule(tp2) =>
26102616 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
26162621 case (tp1 : Type , tp2 : Type ) if defn.isTupleType(tp1) =>
26172622 provablyDisjoint(tp1.toNestedPairs, tp2)
26182623 case (tp1 : Type , tp2 : Type ) if defn.isTupleType(tp2) =>
0 commit comments