Conversation
CatarinaGamboa
left a comment
There was a problem hiding this comment.
For the nullness check, I think we need more cases, like what if we declare the var and it doesn't have a value?
There are full tools just for the nullness checking (e.g., NullAway https://github.com/uber/NullAway)
PS: this would be so much easier if it were 2 prs, one for null and one for boxed types -- the boxed types would be an easy squash and merge
...va-verifier/src/main/java/liquidjava/processor/refinement_checker/RefinementTypeChecker.java
Outdated
Show resolved
Hide resolved
This comment was marked as resolved.
This comment was marked as resolved.
CatarinaGamboa
left a comment
There was a problem hiding this comment.
This is nice to have, but I have some questions (we already discussed some offline):
obj != nulland state. It would be great if we didnt have to pollute the refinements with always having to writethis != null. Maybe we can assume that all object states imply!= null?- null of fields are trickier, check the comment below
| Integer x; // implicit null | ||
|
|
||
| void test() { | ||
| mustBeNull(x); |
There was a problem hiding this comment.
But we don't know if this is null right? how do we know? what if there was a constructor, what if another method is called first and sets this fiels? what are the assumptions here?
There was a problem hiding this comment.
Yeah you're right. I'll try to handle those cases.
This PR adds support for null checking in LiquidJava.
Changes
Refinements Language
nullliteral to the grammarLiteralNullAST nodeTyping
nullcan be assigned to any non-primitive type_ != null, while the literalnullcarries the refinement_ == null_ == nullZ3 Translation
java.lang.Objectnullliterals are converted to the sort of the other operand to match both sortsSimplification
s == -1 && s != nullsimplifies tos == -1instead of-1 != nullTesting