Skip to content

Commit 71cc84b

Browse files
committed
Remove disjointness of invariant type params based on isSameType.
It does not seem to bring anything in practice, and it is easier to specify things without it.
1 parent a84fbb1 commit 71cc84b

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

compiler/src/dotty/tools/dotc/core/TypeComparer.scala

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3010,20 +3010,9 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
30103010
def covariantDisjoint(tp1: Type, tp2: Type, tparam: TypeParamInfo): Boolean =
30113011
provablyDisjoint(tp1, tp2, pending) && typeparamCorrespondsToField(cls.appliedRef, tparam)
30123012

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.
30223014
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)
30273016

30283017
args1.lazyZip(args2).lazyZip(cls.typeParams).exists {
30293018
(arg1, arg2, tparam) =>

0 commit comments

Comments
 (0)