@@ -64,14 +64,13 @@ public ProgramState checkPreStatement(CheckerContext context, Tree syntaxNode) {
6464 // stack is empty, nothing to do.
6565 return context .getState ();
6666 }
67- if (syntaxNode .is (Tree .Kind .MEMBER_SELECT )) {
68- return checkMemberSelect (context , (MemberSelectExpressionTree ) syntaxNode , currentVal );
69- }
67+ Tree toCheck = syntaxNode ;
7068 if (syntaxNode .is (Tree .Kind .METHOD_INVOCATION )) {
7169 MethodInvocationTree methodInvocation = (MethodInvocationTree ) syntaxNode ;
72- if (methodInvocation .methodSelect ().is (Tree .Kind .MEMBER_SELECT )) {
73- return checkMemberSelect (context , (MemberSelectExpressionTree ) methodInvocation .methodSelect (), currentVal );
74- }
70+ toCheck = methodInvocation .methodSelect ();
71+ }
72+ if (toCheck .is (Tree .Kind .MEMBER_SELECT )) {
73+ return checkMemberSelect (context , (MemberSelectExpressionTree ) toCheck , currentVal );
7574 }
7675 return context .getState ();
7776 }
@@ -86,10 +85,6 @@ private ProgramState checkMemberSelect(CheckerContext context, MemberSelectExpre
8685 context .reportIssue (syntaxNode , this , "NullPointerException might be thrown as '" + SyntaxTreeNameFinder .getName (syntaxNode ) + "' is nullable here" );
8786 return null ;
8887 }
89- if (context .getState ().getConstraint (currentVal ) == null ) {
90- // we dereferenced the symbolic value so we can assume it is not null
91- return currentVal .setSingleConstraint (context .getState (), ObjectConstraint .NOT_NULL );
92- }
9388 return context .getState ();
9489 }
9590
@@ -109,10 +104,7 @@ public ProgramState checkPostStatement(CheckerContext context, Tree syntaxNode)
109104
110105 private static List <ProgramState > setNullConstraint (CheckerContext context , Tree syntaxNode ) {
111106 SymbolicValue val = context .getState ().peekValue ();
112- if (syntaxNode .is (Tree .Kind .NULL_LITERAL )) {
113- // invariant to check that value was correctly evaluated.
114- assert val != null && val .equals (SymbolicValue .NULL_LITERAL );
115- } else if (syntaxNode .is (Tree .Kind .METHOD_INVOCATION ) && isAnnotatedCheckForNull ((MethodInvocationTree ) syntaxNode )) {
107+ if (syntaxNode .is (Tree .Kind .METHOD_INVOCATION ) && isAnnotatedCheckForNull ((MethodInvocationTree ) syntaxNode )) {
116108 List <ProgramState > states = new ArrayList <>();
117109 states .addAll (val .setConstraint (context .getState (), ObjectConstraint .NULL ));
118110 states .addAll (val .setConstraint (context .getState (), ObjectConstraint .NOT_NULL ));
0 commit comments