scala/scala — pull request #2051 by adriaanm (2013-02-01 22:03:33+00:00)
Title: SI-7039 unapplySeq result type independent of subpattern count

Fixes a bug in the implementation of the `unapplySeq` part of the spec below.

An `unapplySeq` method in an object x matches the pattern x(p_1, ..., p_n) if:
- it takes exactly one argument and
- its result type is of the form Option[S], where
- S is a subtype of Seq[U] for some element type U, (set m = 0)
- or S is a ProductX[T_1, ..., T_m] and T_m <: Seq[U] (m <= n).
- The argument patterns p_1, ..., p_n are typed with expected types
T_1, ..., T_m, U, ..., U. Where U is repeated n-m times.

An `unapply` method in an object x matches the pattern x(p_1, ..., p_n) if
- it takes exactly one argument and:
- n = 0 and unapply’s result type is Boolean.
- or, n = 1 and unapply’s result type is Option[T], for some type T.
The argument pattern p1 is typed in turn with expected type T.
- or, n > 1 and unapply’s result type is Option[(T_1, ..., T_n)],
for some types T_1, ..., T_n.
The argument patterns p_1, ..., p_n are typed with
expected types T_1, ..., T_n.

review by @retronym, /cc @jrudolph (thanks for the original patch in #2004!)