@@ -3010,20 +3010,9 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
3010
3010
def covariantDisjoint (tp1 : Type , tp2 : Type , tparam : TypeParamInfo ): Boolean =
3011
3011
provablyDisjoint(tp1, tp2, pending) && typeparamCorrespondsToField(cls.appliedRef, tparam)
3012
3012
3013
- // In the invariant case, we also use a stronger notion of disjointness:
3014
- // we consider fully instantiated types not equal wrt =:= to be disjoint
3015
- // (under any context). This is fine because it matches the runtime
3016
- // semantics of pattern matching. To implement a pattern such as
3017
- // `case Inv[T] => ...`, one needs a type tag for `T` and the compiler
3018
- // is used at runtime to check it the scrutinee's type is =:= to `T`.
3019
- // Note that this is currently a theoretical concern since Dotty
3020
- // doesn't have type tags, meaning that users cannot write patterns
3021
- // that do type tests on higher kinded types.
3013
+ // In the invariant case, direct type parameter disjointness is enough.
3022
3014
def invariantDisjoint (tp1 : Type , tp2 : Type , tparam : TypeParamInfo ): Boolean =
3023
- provablyDisjoint(tp1, tp2, pending) ||
3024
- ! isSameType(tp1, tp2) &&
3025
- fullyInstantiated(tp1) && // We can only trust a "no" from `isSameType` when
3026
- fullyInstantiated(tp2) // both `tp1` and `tp2` are fully instantiated.
3015
+ provablyDisjoint(tp1, tp2, pending)
3027
3016
3028
3017
args1.lazyZip(args2).lazyZip(cls.typeParams).exists {
3029
3018
(arg1, arg2, tparam) =>
0 commit comments