Pre-SIP : Proper Specification for Match Types

For once, thanks to the quantitative analysis we conducted, we actually know how they were “abused” in the entire open-source (published on Maven Central) ecosystem. Of course, we never know about closed-source software, nor did we analyze source code available on the net but without any published binaries.

From what I saw in tests (but not in published libraries), the most reasonable use case is to typetest+capture using either an & type (which only ever worked by chance) or a constrained type alias like type IsSeq[t <: Seq[Any]] = t (which is a bit better). This use case has a standard workaround of decomposing into two nested match types: one for typetesting, and one for capturing.

If there’s one direction in which to consider expanding the set of legal match types, I would go for a proper solution to this use case. And while doing so, using dedicated syntax for it like case List[t <: Bound] => would be better IMO.

1 Like