Skip to content

Commit c290a26

Browse files
committed
refine satisfiable
1 parent 5bc9fcb commit c290a26

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

compiler/src/dotty/tools/dotc/transform/patmat/Space.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -708,18 +708,18 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
708708
else text
709709
}
710710

711-
/** Whether the counterexample is satisfiable */
711+
/** Whether the counterexample is satisfiable. The space is flattened and non-empty. */
712712
def satisfiable(sp: Space): Boolean = {
713713
def genConstraint(space: Space): List[(Type, Type)] = space match {
714714
case Prod(tp, unappTp, unappSym, ss, _) =>
715715
val tps = signature(unappTp, unappSym, ss.length)
716716
ss.zip(tps).flatMap {
717-
case (sp: Prod, _) => genConstraint(sp)
717+
case (sp : Prod, tp) => sp.tp -> tp :: genConstraint(sp)
718718
case (Typ(tp1, _), tp2) => tp1 -> tp2 :: Nil
719-
// case _ => ??? // impossible
719+
case _ => ??? // impossible
720720
}
721721
case Typ(_, _) => Nil
722-
// case _ => ??? // impossible
722+
case _ => ??? // impossible
723723
}
724724

725725
def checkConstraint(constrs: List[(Type, Type)]): Boolean = {
@@ -738,7 +738,7 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
738738
}
739739
}
740740

741-
constrs.foldLeft(true) { case (acc, (tp1, tp2)) => acc && typeParamMap(tp1) <:< typeParamMap(tp2) }
741+
constrs.forall { case (tp1, tp2) => typeParamMap(tp1) <:< typeParamMap(tp2) }
742742
}
743743

744744
checkConstraint(genConstraint(sp))

tests/patmat/gadt-nontrivial2.check

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
13:

0 commit comments

Comments
 (0)