Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add validation test for JEP 432: Record Patterns #1415

Merged
merged 2 commits into from Mar 27, 2023

Conversation

Godin
Copy link
Member

@Godin Godin commented Mar 22, 2023

No description provided.

@Godin Godin added this to the 0.8.9 milestone Mar 22, 2023
@Godin Godin added this to Implementation in Current work items via automation Mar 22, 2023
@Godin Godin self-assigned this Mar 22, 2023
@Godin Godin marked this pull request as ready for review March 22, 2023 20:25
@Godin Godin requested a review from marchof March 22, 2023 20:25
@Godin Godin moved this from Implementation to Review in Current work items Mar 22, 2023
@marchof
Copy link
Member

marchof commented Mar 23, 2023

Hi @Godin , a couple of lines are assertPartlyCovered(), which I would not expect from the execution paths. Any idea why?

@Godin
Copy link
Member Author

Godin commented Mar 23, 2023

@marchof not just an idea - I had a look into the current compiler implementation and bytecode that it currently produces 😉

Partial coverage and missed branches are due to how Record Patterns are compiled and seems that we will need to implement filter(s) for a few things:

To support split-compilation (Record can be changed and recompiled after Pattern) deconstruction of each Record component is compiled into a call of component accessor inside of try-catch block

Point p = (Point) o;
try { x = p.x(); } catch (Throwable t) { throw new MatchException(t.toString(), t); }

This also provides support for other cases when accessor throws an exception.

Also enhanced-for-statement under the hood compiles into for with switch, and switch is exhaustive so in its turn contains an additional branch that also throws MatchException.

@marchof marchof merged commit 461ebf3 into jacoco:master Mar 27, 2023
21 checks passed
Current work items automation moved this from Review to Done Mar 27, 2023
@Godin Godin deleted the jep432_record_patterns branch March 27, 2023 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants