Issue #11220: False positive in MissingSwitchDefault with pattern in switch label#11221
Conversation
7bbd54b to
e4b6731
Compare
e4b6731 to
369e5b5
Compare
8e3e43b to
6702d33
Compare
06f1f01 to
21925fb
Compare
| * @param caseGroupAst first case group to check. | ||
| * @return true if 'default' switch found. | ||
| */ | ||
| private static boolean containsDefaultSwitch(DetailAST caseGroupAst) { |
There was a problem hiding this comment.
Changed the name of this method to be consistent with language from the JLS: https://docs.oracle.com/javase/specs/jls/se17/preview/specs/patterns-switch-jls.html
This language is also used throughout the check for consistency.
| void m2(String s) { | ||
| switch (s) { // ok | ||
| case "a": throw new AssertionError("Wrong branch."); | ||
| case default: break; |
There was a problem hiding this comment.
default case label
|
Github, generate report |
21925fb to
d7e667e
Compare
|
GitHub, rebase |
b89b1d1 to
f91ef50
Compare
81fdc35 to
314603a
Compare
|
Github, generate site |
314603a to
8d658f0
Compare
|
Github, generate site |
39983b1 to
d50c431
Compare
|
GitHub, generate web site |
|
Github, rebase |
d50c431 to
260d82b
Compare
| the compiler requires switch expressions to be exhaustive, | ||
| so this check does not enforce default branches on | ||
| such expressions. | ||
| such expressions. Also, switch statements that use pattern or null |
There was a problem hiding this comment.
@romani Am I missing something that this file looks manually changed and isn't using the description in the javadoc and xdoc?
There was a problem hiding this comment.
@nmancus1 Are you manually modifying this file?
There was a problem hiding this comment.
Are you manually modifying this file?
No.
There was a problem hiding this comment.
Such files are updated by test that generate meta data
…attern in switch label
260d82b to
2e8759e
Compare
|
GitHub, generate web site |
Closes #11220
Report label: all projects
Diff Regression config: https://gist.githubusercontent.com/nmancus1/3db3e23a5063857160d7d92cbdfa1bfe/raw/b8fc9b284c6604bf0862f237f030794bfb0a7800/config.xml
Diff Regression projects: https://raw.githubusercontent.com/checkstyle/contribution/e34312d61da0b073f31339cfbf385f289b721fed/checkstyle-tester/projects-to-test-on-for-github-action.properties
Final report: https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/f5590ec_2022232703/reports/diff/index.html
Only diffs are in openjdk17, in noncompilable files. I am not sure if we should add files filters for these files, though, since they are how I confirmed logic of check update. I think that they might be valuable in the future for similar reasons.
Blocked until #11100
Only last commit is under review.
Example of compile error on new enum value: