I simplified the example. I have the feeling it's the new unapply patterns at the root of this bug, but I'm not sure. Here's what I know:
- the first typed pattern (e: SpecialException) does not conform to the prototype (java.lang.Throwable). Instead of failing, the type checker changes it to (e: Throwable with SpecialException).
- Erasure makes 'e' just a Throwable, and adds the appropriate casts in the body. Since this happens after patternmatching, the additional check for SpecialException is missing.
- the backend adds an exception handler for Throwable, which catches everything.
The spec says that the patterns in a try-catch must conform to Throwable, and does not say anything about the silent addition of Throwable. But I guess the original poster's intuition, that pattern matching and exception matching should agree, is the right one.
|