Closed
Description
The following code is currently not supported by the compiler:
object U:
def unapply(s:String): String *: EmptyTuple = Tuple1(s)
"hello" match
case U(x) =>
If we change String *: EmptyTuple
to Tuple1[String]
, it will compile without problem.
The problem is that according to the current specification, String *: EmptyTuple
does not qualify as a product pattern, as it does not contain selectors _1, ..., _N
.
The question is:
- Whether we should support
String *: EmptyTuple
? - How to change the specification?
One particular concern is that making *:
a special case seems to cancel the past efforts to make pattern match more generic.
Related PR: #10987