Change primitive handling in RemoveObjectsIsNull#3918
Conversation
|
Turns out our recipe and tests were handling primitives weirdly; relying on a cast from |
Fixes #3916
koppor
left a comment
There was a problem hiding this comment.
Sponteneous comments just checking the diff.
| if (a != null) { | ||
| System.out.println("a is non-null"); | ||
| public void test(boolean a) { | ||
| if (isNull(a)) { |
There was a problem hiding this comment.
I had my doubts about this case; when we upcast from boolean to Boolean it doesn't really make sense to even call isNull with an upcast to Boolean for that method call. Perhaps we should completely remove the method call in those cases?
There was a problem hiding this comment.
Oh, yeah! And replace !isNull by false 😅
There was a problem hiding this comment.
Yup; I've changed the logic now to add simple true or false instead. In rewrite-launchdarkly we follow such a replacement up with SimplifyConstantIfBranchExecution, but that would require this recipe to move to rewrite-static-analysis. 🤔
Fixes #3915
Fixes #3916