-
-
Notifications
You must be signed in to change notification settings - Fork 358
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
Conversation
…e4377 � Conflicts: � src/test/java/spoon/test/record/CtRecordTest.java � src/test/resources/records/CompactConstructor.java
Please review. This fixes #4377. |
@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
|
There was a problem hiding this 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... :)
if (e instanceof CtAssignment) { | ||
e.setImplicit((node.bits & ASTNode.IsImplicit) != 0); | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
|
||
import org.junit.Ignore; | ||
import org.junit.jupiter.api.Disabled; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
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.