Skip to content

Commit

Permalink
Merge pull request #8820 from dotty-staging/fix-8757
Browse files Browse the repository at this point in the history
Fix #8757: check wildcard star patterns by tree instead of type
  • Loading branch information
smarter committed Apr 28, 2020
2 parents 8fed152 + 71f5b3a commit dd42e2a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/transform/patmat/Space.scala
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,8 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
def projectSeq(pats: List[Tree]): Space = {
if (pats.isEmpty) return Typ(scalaNilType, false)

val (items, zero) = if (pats.last.tpe.isRepeatedParam)
(pats.init, Typ(scalaListType.appliedTo(pats.last.tpe.argTypes.head), false))
val (items, zero) = if (isWildcardStarArg(pats.last))
(pats.init, Typ(scalaListType.appliedTo(pats.last.tpe.elemType), false))
else
(pats, Typ(scalaNilType, false))

Expand Down
1 change: 1 addition & 0 deletions tests/patmat/i8757.check
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8: Pattern Match Exhaustivity: C()
10 changes: 10 additions & 0 deletions tests/patmat/i8757.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
sealed trait T

case class C(xs: Int*) extends T

def f(): Unit = (C(42): T) match { case C(xs: _*) => }
def g(): Unit = (C(42): T) match { case C(_: _*) => }

def h(): Unit = (C(42): T) match
case C(5, _: _*) =>
case C(x, xs: _*) =>

0 comments on commit dd42e2a

Please sign in to comment.