Skip to content

Commit ba82f73

Browse files
committed
Move test to deep subtype
1 parent 9aec96d commit ba82f73

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2535,6 +2535,8 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
25352535
/** If some (&-operand of) `tp` is a supertype of `sub` replace it with `NoType`.
25362536
*/
25372537
private def dropIfSuper(tp: Type, sub: Type): Type =
2538+
// We need to be careful to check branches of AndTypes and OrTypes in correct order,
2539+
// see discussion in issue #20516.
25382540
tp match
25392541
case tp @ AndType(tp1, tp2) =>
25402542
recombine(dropIfSuper(tp1, sub), dropIfSuper(tp2, sub), tp)
@@ -2546,6 +2548,8 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
25462548

25472549
/** If some (|-operand of) `tp` is a subtype of `sup` replace it with `NoType`. */
25482550
private def dropIfSub(tp: Type, sup: Type, canConstrain: Boolean): Type =
2551+
// We need to be careful to check branches of AndTypes and OrTypes in correct order,
2552+
// see discussion in issue #20516.
25492553
tp match
25502554
case tp @ OrType(tp1, tp2) =>
25512555
recombine(dropIfSub(tp1, sup, canConstrain), dropIfSub(tp2, sup, canConstrain), tp)
File renamed without changes.

0 commit comments

Comments
 (0)