You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//An unapplySeq for extractor can offer Option[Seq[S]] or Option[(A, B, Seq[S])].//Omitting the Seq:
scala>objectX { defunapplySeq(v: Any) =Option((1, 2, 3)) }
defined objectX
scala>valX(x, y, z) =null
<console>:12:error: too many patterns forobjectX offering (Int, Int): expected 2, found 3valX(x, y, z) =null
^
scala>valX(x, y) =null
x:Int=1
y:Int=2
scala>valX(x, y, _*) =null
<console>:14:error: Star pattern must correspond with varargs or unapplySeq
valX(x, y, _*) =null
^
// the bug permits idiom for avoiding SI-6675// since apparently no tupling for unapplySeq
scala>valX(x) =null
<console>:13:error: not enough patterns forobjectX offering (Int, Int): expected 2, found 1valX(x) =null
^
The text was updated successfully, but these errors were encountered:
Welcome to Scala 2.13.6 (OpenJDK 64-Bit Server VM, Java 17-ea).
Type in expressions for evaluation. Or try :help.
scala> object X { def unapplySeq(v: Any) = Option((1, 2, 3)) }
object X
scala> val X(x, y, z) = null
^
error: too many patterns for object X offering (Int, Int): expected 2, found 3
scala> val X(x, y) = null
scala.MatchError: null
... 32 elided
but
scala> object X { def unapplySeq(v: Any) = Option((1, 2, 3)) }
// defined object X
scala> val X(x, y, z) = null
1 |val X(x, y, z) = null
| ^^^^^^^^^^
| Option[(Int, Int, Int)] is not a valid result type of an unapplySeq method of an extractor.
1 |val X(x, y, z) = null
|^
|Recursive value $1$ needs type
Confirmed the reported behavior for 2.12.13, it's not a milestone thing.
The text was updated successfully, but these errors were encountered: