Skip to content

Test case for Pattern.pattern and Pattern.toString#1590

Open
wmdietl wants to merge 2 commits intomasterfrom
pattern-regexes
Open

Test case for Pattern.pattern and Pattern.toString#1590
wmdietl wants to merge 2 commits intomasterfrom
pattern-regexes

Conversation

@wmdietl
Copy link
Copy Markdown
Member

@wmdietl wmdietl commented Mar 13, 2026

Merge with eisop/jdk#132

Fixes typetools issue 7539 properly by using PolyRegex on the return and receiver types.
This preserves the regex information, instead of over-approximating it as @Regex.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a regression test in the regex checker test suite to ensure java.util.regex.Pattern.pattern() and Pattern.toString() preserve precise regex group-count information (via PolyRegex), addressing typetools issue typetools#7539 without over-approximating results as plain @Regex.

Changes:

  • Introduce a new compilation test covering Pattern.pattern() and Pattern.toString() result usage in Pattern.compile.
  • Verify group-count precision is preserved by expecting group(3) to be rejected when the pattern has only 2 capturing groups.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Added closed issue typetools#7539 to the changelog.
@wmdietl
Copy link
Copy Markdown
Member Author

wmdietl commented Mar 13, 2026

Blocked on #1592.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants