Repository navigation
Add support on the dataflow CFG for visiting lambda result expressions - #1516
Conversation
|
I am also not sure if there is any other code internally in the checkerframework that needs to be updated to treat |
This commit: - Adds https://github.com/msridhar/checker-framework (repository branch) as a maven repository for our build.gradle - Forces the 2.1.14-nullaway checker framework dataflow jar (but uses upstream javacutil.jar for same version). Forcing needed, as 2.1.14-* < 2.1.14 for dependency resolution. - Adds the shadow maven plug-in allowing us to create a semi-fat jar using `gradle shadowJar` which contains NullAway and the checker framework fork, but not, say, EP or javax. - Removes our hack around a CF fix we backported into our fork: typetools/checker-framework#1516
This commit: - Adds https://github.com/msridhar/checker-framework (repository branch) as a maven repository for our build.gradle - Forces the 2.1.14-nullaway checker framework dataflow jar (but uses upstream javacutil.jar for same version). Forcing needed, as 2.1.14-* < 2.1.14 for dependency resolution. - Adds the shadow maven plug-in allowing us to create a semi-fat jar using `gradle shadowJar` which contains NullAway and the checker framework fork, but not, say, EP or javax. - Removes our hack around a CF fix we backported into our fork: typetools/checker-framework#1516
This commit: - Adds https://github.com/msridhar/checker-framework (repository branch) as a maven repository for our build.gradle - Forces the 2.1.14-nullaway checker framework dataflow jar (but uses upstream javacutil.jar for same version). Forcing needed, as 2.1.14-* < 2.1.14 for dependency resolution. - Adds the shadow maven plug-in allowing us to create a semi-fat jar using `gradle shadowJar` which contains NullAway and the checker framework fork (shaded), but not, say, EP or javax. - Removes our hack around a CF fix we backported into our fork: typetools/checker-framework#1516 - Pulls in some code from Error Prone that did not interact well with the shaded checker-framework. Namely from: com.google.errorprone.dataflow.nullnesspropagation.*
wmdietl
left a comment
There was a problem hiding this comment.
Hi @lazaroclapp ,
sorry for being so late on this PR. I have a few small comments that would be nice to address before merging.
Thanks!
cu, WMD.
|
|
||
| public LambdaResultExpressionNode( | ||
| ExpressionTree t, /*@Nullable*/ Node result, Types types /*, | ||
| LambdaExpressionTree lambda, |
| */ | ||
| public class LambdaResultExpressionNode extends Node { | ||
|
|
||
| protected ExpressionTree tree; |
There was a problem hiding this comment.
Can you add some documentation what the tree and result represent, either here or, maybe better, with the public getter methods?
There was a problem hiding this comment.
Adding it to the methods, let me know if its clear enough (working on the code as I reply to the comments, will update the PR shortly).
| super(InternalUtils.typeOf(t)); | ||
| this.result = result; | ||
| tree = t; | ||
| //result.setAssignmentContext(new AssignmentContext.LambdaReturnContext(methodSymbol)); |
There was a problem hiding this comment.
Did you run into any problems with the assignment context? Does this require more work or can this comment be removed?
There was a problem hiding this comment.
No problems here of interest. Removing, this is left-over code from another approach at this.
| LambdaResultExpressionNode other = (LambdaResultExpressionNode) obj; | ||
| if ((result == null) != (other.result == null)) { | ||
| return false; | ||
| } |
There was a problem hiding this comment.
Can you add a comment why the tree doesn't need to be compared?
There was a problem hiding this comment.
Comment added. This code is inspired by ReturnNode. Basically if we are constructing LambdaResultExpressionNode's correctly, then result is supposed to be scan([path_to_tree], null), which means just checking result should be enough. If we decide this is not the case, then we need to change both this one and ReturnNode.
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return HashCodeUtils.hash(result); |
There was a problem hiding this comment.
Similarly, why does the hash only depend on the result, not on the tree? Maybe this is something to document with the fields, also.
|
Regarding other code changes: I tested your changes a bit and everything seemed to work as expected - we already had test coverage for lambdas with single expressions. |
… a lambda. This adds a new node to the cfg, LambdaResultExpressionNode, which corresponds to the result of a lambda expression with a single expression as its body, and which is added at the end of the cfg when CFGBuilder is passed a CFGLambda of this kind as the underlaying ast. This is needed by some analyses to handle the result of a lambda expression in the case where the body is a single ExpressionTree. The case where the body is a block is already handled by matching ReturnNode.
52d4c3a to
451f7c6
Compare
|
Rebased and addressed the above comments. Thanks!! :) |
This adds a new node to the cfg, LambdaResultExpressionNode, which corresponds
to the result of a lambda expression with a single expression as its body, and
which is added at the end of the cfg when CFGBuilder is passed a CFGLambda of
this kind as the underlaying ast.
This is needed by some analyses to handle the result of a lambda expression in
the case where the body is a single ExpressionTree. The case where the body is
a block is already handled by matching ReturnNode.