Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion compiler/src/dotty/tools/dotc/transform/patmat/Space.scala
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,12 @@ object SpaceEngine {
project(pat)

case Typed(_, tpt) =>
Typ(erase(tpt.tpe.stripAnnots, isValue = true, isTyped = true), decomposed = false)
val tptTpe =
if isWildcardStarArg(pat) then
tpt.tpe.translateFromRepeated(toArray = false)
else
tpt.tpe
Typ(erase(tptTpe.stripAnnots, isValue = true, isTyped = true), decomposed = false)

case This(_) =>
Typ(pat.tpe.stripAnnots, decomposed = false)
Expand Down
6 changes: 6 additions & 0 deletions tests/warn/i23459.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-- [E092] Pattern Match Unchecked Warning: tests/warn/i23459.scala:7:14 ------------------------------------------------
7 | case Test(x*) => println(x) // warn
| ^
|the type test for Seq[Int]* cannot be checked at runtime because its type arguments can't be determined from Seq[Int]
|
| longer explanation available when compiling with `-explain`
8 changes: 8 additions & 0 deletions tests/warn/i23459.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
case class Test()
object Test:
def unapply(t: Test): Some[Seq[Int]] = Some(Seq(1, 2))

@main def run(): Unit =
Test() match
case Test(x*) => println(x) // warn

6 changes: 6 additions & 0 deletions tests/warn/i23459b.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-- [E092] Pattern Match Unchecked Warning: tests/warn/i23459b.scala:7:14 -----------------------------------------------
7 | case Test(_*) => () // warn
| ^
|the type test for Seq[Int]* cannot be checked at runtime because its type arguments can't be determined from Seq[Int]
|
| longer explanation available when compiling with `-explain`
8 changes: 8 additions & 0 deletions tests/warn/i23459b.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
case class Test()
object Test:
def unapply(t: Test): Some[Seq[Int]] = Some(Seq(1, 2))

@main def run(): Unit =
Test() match
case Test(_*) => () // warn

Loading