scala/scala — pull request #2168 by retronym (2013-02-25 21:00:26+00:00)
Title: SI-7183 Disable unreachability for withFilter matches.

This avoids spurious unreachable warnings on code
that the user didn't write.

The parser desugars for-comprehensions such as:

for (A(a) <- List(new A)) yield a

To:

List(new A()).withFilter(((check$ifrefutable$2) =>
check$ifrefutable$2: @scala.unhecked match {
case A((a @ _)) => true
case _ => false
})
)

But, if `A.unapply` returns `Some[_]`, the last case is dead code.
(Matching against a regular case class *would* fall through in
the caes of a null scrutinee.)

In SI-6902, we enabled unreachability warnings, even if the
scrutinee was annotated as @unchecked. That was consistent
with the 2.9.2 behaviour, it was only disabled temporarily
(actually, accidentally) in 2.10.0. But, the old pattern matcher
didn't warn about this code.

This commit makes the pattern matcher recognise the special
scrutinee based on its name and disables both exhaustivity
*and* unreachability analysis.

To do so, the we generalize the boolean flag `unchecked` to
the class `Suppression`.

Review by @adriaanm.

This one shows up on typical usage of Slick, so I think its a fairly important regression. We need to get better at internal testing of new Scala releases; we had a regression from each of SBT, Akka, and Slick show up very late in the cycle.

```
/Users/jason/code/slick/slick-testkit/src/main/scala/com/typesafe/slick/testkit/tests/NestingTest.scala:20: warning: unreachable code
a ~ b <- mapped
```