WIP: fix EqualsAvoidsNull not idempotent#487
Closed
Pankraz76 wants to merge 8 commits into
Closed
Conversation
EqualsAvoidsNull not idempotent
6903257 to
b26b5a5
Compare
added 3 commits
March 28, 2025 19:36
added 2 commits
March 28, 2025 20:15
Comment on lines
+20
to
21
| import org.jetbrains.annotations.NotNull; | ||
| import org.jspecify.annotations.Nullable; |
Contributor
There was a problem hiding this comment.
Suggested change
| import org.jetbrains.annotations.NotNull; | |
| import org.jspecify.annotations.Nullable; | |
| import org.jspecify.annotations.Nullable; |
| /** | ||
| * @implNote {@link MultipleVariableDeclarationsVisitor#visitBlock(J.Block, ExecutionContext)} | ||
| */ | ||
| private J.@NotNull Block visitBlock(J.Block b) { |
Contributor
There was a problem hiding this comment.
Suggested change
| private J.@NotNull Block visitBlock(J.Block b) { | |
| private J. Block visitBlock(J.Block b) { |
Pankraz76
commented
Mar 28, 2025
| if (!isStringComparisonMethod(m) || !hasCompatibleArgument(m) || m.getSelect() instanceof J.Literal) { | ||
| return m; | ||
| } | ||
| public J.Block visitBlock(J.Block block, ExecutionContext ctx) { |
Contributor
Author
There was a problem hiding this comment.
The variable declaration lookup kind of works:
Now the timing is currently wrong as visitBlock gets called after the visitMethodInvocation function, which then needs to check the pre-built VARIABLE_DECLARATIONS cache to determine which ones to flip and which ones not to. I'm sure you guys can help me or easily take over to add the missing parts.
Contributor
Author
There was a problem hiding this comment.
what do you think, is this any good? @greg-at-moderne @timtebeek
Contributor
Author
|
feel free to overtake or advisory, as im not able to fix this. Thanks @timtebeek |
Contributor
Author
|
nicely fixed by @greg-at-moderne |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


What's changed?
test
EqualsAvoidsNullidempotencyWhat's your motivation?