Skip to content

Commit 23e8437

Browse files
committed
Add explanations for rewritings
1 parent 6f8741a commit 23e8437

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

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

+6
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,9 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
347347
case OrType(tp21, tp22) =>
348348
// Rewrite T1 <: (T211 & T212) | T22 to T1 <: (T211 | T22) and T1 <: (T212 | T22)
349349
// and analogously for T1 <: T21 | (T221 & T222)
350+
// `|' types to the right of <: are problematic, because
351+
// we have to choose one constraint set or another, which might cut off
352+
// solutions. The rewriting delays the point where we have to choose.
350353
tp21 match {
351354
case AndType(tp211, tp212) =>
352355
return isSubType(tp1, OrType(tp211, tp22)) && isSubType(tp1, OrType(tp212, tp22))
@@ -460,6 +463,9 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
460463
case AndType(tp11, tp12) =>
461464
// Rewrite (T111 | T112) & T12 <: T2 to (T111 & T12) <: T2 and (T112 | T12) <: T2
462465
// and analogously for T11 & (T121 | T122) & T12 <: T2
466+
// `&' types to the left of <: are problematic, because
467+
// we have to choose one constraint set or another, which might cut off
468+
// solutions. The rewriting delays the point where we have to choose.
463469
tp11 match {
464470
case OrType(tp111, tp112) =>
465471
return isSubType(AndType(tp111, tp12), tp2) && isSubType(AndType(tp112, tp12), tp2)

0 commit comments

Comments
 (0)