Skip to content

Conversation

@romainbrenguier
Copy link
Contributor

@romainbrenguier romainbrenguier commented Jun 13, 2025

Samples with generic record patterns as added in the unit test, were causing UnsupportedOperationExceptions
@hashicorp-vault-sonar-prod hashicorp-vault-sonar-prod bot changed the title Fix issue in CFG computation with generic record pattern SONARJAVA-5621 Fix issue in CFG computation with generic record pattern Jun 13, 2025
Copy link
Contributor

Choose a reason for hiding this comment

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

The change looks good but we can probably extend the test code with bounded types.
We should also improve the ticket to give it the appropriate type (bug?), affected version and description.

void generic_record_pattern() {
CFG cfg = buildCFG("""
private static boolean testGen3(Object o) throws Throwable {
return o instanceof GenRecord1<?, ?>(Integer i, var s) && i.intValue() == 3 && s.length() == 0;

Choose a reason for hiding this comment

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

I am trying some corner cases here but we should probably test with a bounded wild card

Choose a reason for hiding this comment

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

return o instanceof GenRecord1<?, ? extends CharSequence>(Integer i, var s) && i.intValue() == 3 && s.length() == 0;

@sonarqube-next
Copy link

Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM 👍🏿 Thanks for adding the new test case!

@romainbrenguier romainbrenguier merged commit 54ebc25 into master Jun 13, 2025
15 of 16 checks passed
@romainbrenguier romainbrenguier deleted the romain/bugfix/cfg-generic-record-pattern branch June 13, 2025 14:12
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