Skip to content

Conversation

crogoz
Copy link
Contributor

@crogoz crogoz commented Sep 25, 2025

Before this PR

After this PR

Fixes parsing of switch expressions that have a comment before the closing "}". (internal example here with the corresponding failure here). Internal discussion here
==COMMIT_MSG==
Fix comments after default switch case expressions
==COMMIT_MSG==

Possible downsides?

@changelog-app
Copy link

changelog-app bot commented Sep 25, 2025

Generate changelog in changelog/@unreleased

Type (Select exactly one)

  • Feature (Adding new functionality)
  • Improvement (Improving existing functionality)
  • Fix (Fixing an issue with existing functionality)
  • Break (Creating a new major version by breaking public APIs)
  • Deprecation (Removing functionality in a non-breaking way)
  • Migration (Automatically moving data/functionality to a new system)

Description

Fix comments after default switch case expressions

Check the box to generate changelog(s)

  • Generate changelog entry

@changelog-app
Copy link

changelog-app bot commented Sep 25, 2025

Successfully generated changelog entry!

What happened?

Your changelog entries have been stored in the database as part of our migration to ChangelogV3.

Need to regenerate?

Simply interact with the changelog bot comment again to regenerate these entries.

🔄 Changelog entries were re-generated at Thu, 25 Sep 2025 17:10:52 UTC!

@crogoz crogoz marked this pull request as ready for review September 29, 2025 09:24
esword
esword previously approved these changes Sep 29, 2025
}


public void testWithComments(int y) {

Choose a reason for hiding this comment

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

is this the intended snippet for the before? I couldn't see what the difference was manually, and both diff and difft report no differences.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, without this change, the formatter would put the "}" on the same line as the comment - which breaks the compilation eg.

        x = switch (y) {
            case 1 -> 1;
            // after case 1
            case 2 -> throw new IllegalArgumentException();
            // after case 2
            default -> throw new IllegalStateException();
            // after default case};

Choose a reason for hiding this comment

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

ah, are you able to put that in the description, it's quite hard to tell what's being fixed from just the code + PR description

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've changed the input to a wrongly formatted switch expression here

@policy-bot policy-bot bot dismissed esword’s stale review September 29, 2025 10:24

Invalidated by push of 78dc770

@felixdesouza
Copy link

👍 I keep forgetting invalidated on push on public gh

@bulldozer-bot bulldozer-bot bot merged commit 83d464c into develop Sep 29, 2025
9 checks passed
@bulldozer-bot bulldozer-bot bot deleted the cr/fix-switch-comment branch September 29, 2025 11:33
@autorelease3
Copy link

autorelease3 bot commented Sep 29, 2025

Released 2.75.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants