Skip to content

Commit da8fd5f

Browse files
committed
Fix printing and check files
1 parent b31d00e commit da8fd5f

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ trait SpaceLogic {
167167
def tryDecompose1(tp: Type) = canDecompose(tp) && isSubspace(Or(decompose(tp)), b)
168168
def tryDecompose2(tp: Type) = canDecompose(tp) && isSubspace(a, Or(decompose(tp)))
169169

170-
(simplify(a), b) match {
170+
(simplify(a), simplify(b)) match {
171171
case (Empty, _) => true
172172
case (_, Empty) => false
173173
case (Or(ss), _) =>
@@ -728,6 +728,7 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
728728
checkConstraint(genConstraint(sp))(ctx.fresh.setNewTyperState())
729729
}
730730

731+
def show(ss: Seq[Space]): String = ss.map(show).mkString(", ")
731732
/** Display spaces */
732733
def show(s: Space): String = {
733734
def params(tp: Type): List[Type] = tp.classSymbol.primaryConstructor.info.firstParamTypes
@@ -740,7 +741,7 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
740741
}
741742

742743
def doShow(s: Space, flattenList: Boolean = false): String = s match {
743-
case Empty => ""
744+
case Empty => "empty"
744745
case Typ(c: ConstantType, _) => "" + c.value.value
745746
case Typ(tp: TermRef, _) =>
746747
if (flattenList && tp <:< scalaNilType) ""
@@ -773,11 +774,11 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
773774
val paramsStr = params.map(doShow(_, flattenList = isUnapplySeq)).mkString("(", ", ", ")")
774775
showType(fun.prefix) + paramsStr
775776
}
776-
case Or(_) =>
777-
throw new Exception("incorrect flatten result " + s)
777+
case Or(ss) =>
778+
ss.map(doShow(_, flattenList)).mkString(" | ")
778779
}
779780

780-
flatten(s).map(doShow(_, flattenList = false)).distinct.mkString(", ")
781+
doShow(s, flattenList = false)
781782
}
782783

783784
private def exhaustivityCheckable(sel: Tree): Boolean = {
@@ -831,7 +832,7 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
831832
}
832833

833834
if (uncovered.nonEmpty)
834-
ctx.warning(PatternMatchExhaustivity(show(Or(uncovered))), sel.sourcePos)
835+
ctx.warning(PatternMatchExhaustivity(show(uncovered)), sel.sourcePos)
835836
}
836837

837838
private def redundancyCheckable(sel: Tree): Boolean =

tests/patmat/gadt4.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
12: Pattern Match Exhaustivity: (VC(_, _), VN()), (VN(), VC(_, _))
1+
12: Pattern Match Exhaustivity: (VN(), VC(_, _)), (VC(_, _), VN())

tests/patmat/gadt5.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
63: Pattern Match Exhaustivity: (Try3.VC(_, _), Try3.VN()), (Try3.VN(), Try3.VC(_, _))
1+
63: Pattern Match Exhaustivity: (Try3.VN(), Try3.VC(_, _)), (Try3.VC(_, _), Try3.VN())

0 commit comments

Comments
 (0)