Skip to content

Issue #14891: MissingSwitchDefault should not violate switch that con…#14973

Merged
rnveach merged 1 commit into
checkstyle:masterfrom
checkstyle-GSoC25:recordpattern-missingdefault
Jun 14, 2024
Merged

Issue #14891: MissingSwitchDefault should not violate switch that con…#14973
rnveach merged 1 commit into
checkstyle:masterfrom
checkstyle-GSoC25:recordpattern-missingdefault

Conversation

@mahfouz72

Copy link
Copy Markdown
Member Author

Github, generate report

@mahfouz72 mahfouz72 force-pushed the recordpattern-missingdefault branch from 37bdf86 to 4341db8 Compare June 11, 2024 11:36
@github-actions

Copy link
Copy Markdown
Contributor

@romani

romani commented Jun 11, 2024

Copy link
Copy Markdown
Member

@nrmancuso , @rnveach , try think of we should collect such test bundles (config , list of projects) in our test-configs repository.
This specific is simple default config, but what if any non default come up let's seriously consider to preserve it, or signal to me and Piyush to review.

@relentless-pursuit , as you finish generation of basic set of configs, you will be immediately huge help for others. People will not use gist anymore for simple cases.

@nrmancuso nrmancuso left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let’s go!

@rnveach rnveach left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add one more input example where the switch does have a default.

https://checkstyle.org/checks/coding/missingswitchdefault.html#Description

This check does not validate switch statements that use pattern or null labels. Rationale: Switch statements that use pattern or null labels are checked by the compiler for exhaustiveness.

You made a point to update the javadoc. Shouldn't this be updated as well?

See the Java Language Specification for more information about switch statements and expressions

Shouldn't we update this to the new JLS also show the new patterns?

@mahfouz72

Copy link
Copy Markdown
Member Author

This check does not validate switch statements that use pattern or null labels. Rationale: Switch statements that use pattern or null labels are checked by the compiler for exhaustiveness.

You made a point to update the javadoc. Shouldn't this be updated as well?

I assumed that the word "pattern" in "that use pattern or null labels." includes both normal type patterns and record pattern

@mahfouz72 mahfouz72 force-pushed the recordpattern-missingdefault branch from 4341db8 to e36a233 Compare June 12, 2024 08:23
@mahfouz72

Copy link
Copy Markdown
Member Author

Github, generate site

* and expressions.
* </p>
* <p>
* See the <a href="https://docs.oracle.com/javase/specs/jls/se17/html/jls-14.html#jls-14.30">

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new record pattern syntax introduced in Java 21

I would expect use to use the new JLS in which it was introduced. Update the one before it as well.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@mahfouz72 mahfouz72 force-pushed the recordpattern-missingdefault branch from e36a233 to ba2f05c Compare June 13, 2024 17:25
@mahfouz72

Copy link
Copy Markdown
Member Author

Github, generate site

@rnveach rnveach merged commit 610cff3 into checkstyle:master Jun 14, 2024
@mahfouz72 mahfouz72 deleted the recordpattern-missingdefault branch July 4, 2024 00:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

Add Support for Java 21 Record Pattern : MissingSwitchDefault

4 participants