-
Notifications
You must be signed in to change notification settings - Fork 134
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
Actually support records #1414
Actually support records #1414
Conversation
Generate changelog in
|
isSubtype(getType(tree), Suppliers.typeFromString(t).get(state), state))) { | ||
|
||
Pattern isRecord = Pattern.compile("record\\s+" + tree.getSimpleName() + "\\("); | ||
if (isRecord.matcher(state.getSourceForNode(tree)).find()) { |
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.
This could become expensive, I wonder if we can get away with state.getSourceForNode(tree).startsWith("record ")
?
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.
Unfortunately records can have a visibility modifier so that check doesn't quite work
.addSourceLines( | ||
"Test.java", | ||
"class Test {", | ||
"@SuppressWarnings(\"StrictUnusedVariable\")", |
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.
😂
So are we saying that new error-prone doesn't actually use a modern java compiler that would allow us to use first-class methods to determine if an AST is actually a record?? It does seem very sad to have to regex things :( |
Yes its pretty unfortunate to have to do a regex. We could leave things as is and say that we don't have 100% support for |
I'm going to close this out and say that we only partially support records at the given moment, which seems reasonable given that they are still a preview feature |
Before this PR
I accidentally pushed and merged a test case with a suppression that broke the test: #1412.
After this PR
==COMMIT_MSG==
Actually support records with
StrictUnusedVariable
==COMMIT_MSG==
Possible downsides?
N/A