Closed timw closed 1 year ago
On reflection, I might be expecting too much of the compiler here, as it probably lacks enough information to know that these cases are exhaustive - the warning is "may not be exhaustive" after all, but the fact that there's a case that seems to obviously match the proposed failure pattern seems slightly jarring.
IIUC, https://github.com/scala/bug/issues/12240 is why case Seq(_@_*) =>
correctly does not warn, and this ticket is a duplicate of https://github.com/scala/bug/issues/12252
There is discussion via linked tickets.
Reproduction steps
Scala version: 2.13.10
Compile with
-Xlint:strict-unsealed-patmat
Problem
When compiled with no lints, the above code compiles with no warnings and runs correctly. When compiled with
-Xlint:strict-unsealed-patmat
it produces the warning:Using
case _ +: _
exhibits the same problem. Uncommenting the wildcard case allows compilation with no warnings.This seems incorrect, in that it's evident when run that all the possible Seq cases are matched. The same test case using
List
with the same patterns also fails, but classicList
cons patterns do not exhibit the problem.