-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Switch][Sealed types] Bad static analysis with the old switch syntax + an exhautive pattern matching on a sealed type throws a MatchException #3096
Comments
Thanks for the report Rémi. Reproduced. Smaller test case:
|
Problem dates back to |
an exhautive pattern matching on a sealed type throws a MatchException * Fixes eclipse-jdt#3096
To check and to address separately if needed: whether JDK18- code falls into the compiler inserted default that throws an |
Yes, this scenario is correctly handled. I have added more tests here: #3099 |
Hello,
One of my TA has found the following bug, if a switch is exhautive, i.e. the cases cover all subtypes of the sealed interface, as the JLS says the compiler adds a
default -> throw new MatchException();
and a break is added in the last case if necessary.Here Eclipse fails to properly analyze the
if (bs == null)
so it does not insert the break after the last case so at runtime, the case B fallthrough and throws a MatchException.The text was updated successfully, but these errors were encountered: