Skip to content

Commit 1f13d19

Browse files
committed
Fix printing of counter-examples for List
1 parent 2433be6 commit 1f13d19

File tree

3 files changed

+2
-3
lines changed

3 files changed

+2
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ class SpaceEngine(using Context) extends SpaceLogic {
775775
if (ctx.definitions.isTupleType(tp))
776776
"(" + params.map(doShow(_)).mkString(", ") + ")"
777777
else if (tp.isRef(scalaConsType.symbol))
778-
if (flattenList) params.map(doShow(_, flattenList)).mkString(", ")
778+
if (flattenList) params.map(doShow(_, flattenList)).filter(_.nonEmpty).mkString(", ")
779779
else params.map(doShow(_, flattenList = true)).filter(!_.isEmpty).mkString("List(", ", ", ")")
780780
else {
781781
val sym = fun.symbol

tests/patmat/i12358.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3: Pattern Match Exhaustivity: List(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _*), List(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, ), List(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, ), List(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, ), List(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, ), List(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, )
1+
3: Pattern Match Exhaustivity: List(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _*), List(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _), List(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _), List(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _), List(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _), List(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _)

tests/patmat/i12358.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11

22
def foo(x: List[Int]): Unit =
33
x match
4-
// case x1 :: x2 :: x3 :: x4 :: x5 :: x6 :: x7 :: x8 :: x9 :: x10 :: x11 :: x12 :: x13 :: x14 :: Nil =>
54
case x1 :: x2 :: x3 :: x4 :: x5 :: x6 :: x7 :: x8 :: x9 :: x10 :: x11 :: x12 :: x13 :: x14 :: x15 :: x16 :: x17 :: x18 :: x19 :: x20 :: x21 :: x22 :: Nil =>

0 commit comments

Comments
 (0)