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

fix(record): valid assignments in record compact constructors #4389

Merged
merged 11 commits into from
Jan 6, 2022

Conversation

xzel23
Copy link
Contributor

@xzel23 xzel23 commented Dec 29, 2021

I have created a second test case for record compact constructors to demostrate the problem. I have created a PR even if I don't have a fix yet to make reproducing easier: either run CtRecordTest.testCompactConstructor2() directly from your IDE (in IntelliJ it's possible to run disabled tests from the IDE, don't know about eclipse), or remove the "@disabled" annotation from said method.

@xzel23
Copy link
Contributor Author

xzel23 commented Dec 29, 2021

Please review. This fixes #4377.

@xzel23 xzel23 changed the title Issue4377: spoon adds invalid assignments in record compact constructor (in progress) Issue4377: spoon adds invalid assignments in record compact constructor Dec 29, 2021
@slarse
Copy link
Collaborator

slarse commented Dec 30, 2021

@SirYwell can you review this?

@xzel23 Could you please add "fix #4377" to the PR body (first post)? That will automatically close the issue when this is merged. See this line of the contributing guidelines

If the pull request resolves an issue, simply add "fix #issueNumber" or "close #issueNumber" to the description, see doc

@xzel23 xzel23 changed the title Issue4377: spoon adds invalid assignments in record compact constructor fix #4377: spoon adds invalid assignments in record compact constructor Dec 30, 2021
Copy link
Collaborator

@SirYwell SirYwell left a comment

Choose a reason for hiding this comment

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

I left two comments for possible improvements. The fix itself looks good.

I also figured out why I wasn't able to reproduce it, as I even checked out your commit before you added the fix. I ran the tests with Java 11 locally, and as JDT can't resolve java.lang.Record there, it does not add the assignments... :)

Comment on lines 119 to 121
if (e instanceof CtAssignment) {
e.setImplicit((node.bits & ASTNode.IsImplicit) != 0);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure if this is the best place for this, I think it could also be added to the visit(Assignment, BlockScope) method in JDTTreeBuilder (similar to how it is done here). WDYT?

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, that's of course much better.

Comment on lines 11 to 13

import org.junit.Ignore;
import org.junit.jupiter.api.Disabled;
Copy link
Collaborator

Choose a reason for hiding this comment

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

The annotations aren't used anymore, you can remove them again.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed the imports, will update the PR once I'm done with the other comments and unit tests are green

Copy link
Collaborator

@SirYwell SirYwell left a comment

Choose a reason for hiding this comment

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

Looks good!

@monperrus monperrus changed the title fix #4377: spoon adds invalid assignments in record compact constructor fix(record): valid assignments in record compact constructors Jan 6, 2022
@monperrus monperrus merged commit d134c8b into INRIA:master Jan 6, 2022
@monperrus
Copy link
Collaborator

Thanks a lot @xzel23 for the fix and @SirYwell for the review.

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.

4 participants