-
Notifications
You must be signed in to change notification settings - Fork 290
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
Assertion of not equal to null updates the access path #240
Conversation
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.
Overall this looks great, thanks! We just need a couple of comments to be addressed.
nullaway/src/main/java/com/uber/nullaway/dataflow/AccessPathNullnessPropagation.java
Show resolved
Hide resolved
@@ -114,7 +114,7 @@ public ControlFlowGraph load(CfgParams key) { | |||
codePath.getLeaf(), (ClassTree) codePath.getParentPath().getLeaf()); | |||
bodyPath = codePath; | |||
} | |||
return CFGBuilder.build(bodyPath, ast, false, false, env); | |||
return CFGBuilder.build(bodyPath, ast, true, false, env); |
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 thought we agreed that there would be a command-line flag controlling whether we treat assertions as being on or not?
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 great now! Just one more minor comment
@@ -63,6 +63,8 @@ | |||
*/ | |||
private static final int MAX_CACHE_SIZE = 50; | |||
|
|||
private boolean assertsEnabled; |
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.
Let's make this final
, initialize in the constructor, and get rid of the setAssertionsEnabled()
method
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.
LGTM, will land
Thanks for the contribution @shas19! |
Added support for assert statements that check if the left operand is not equal to null. It will be assumed that the operand is NONNULL, and warnings will change accordingly.
Fixes #122
Added unit tests