You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by GitBox <gi...@apache.org> on 2020/10/01 20:18:40 UTC

[GitHub] [groovy] eric-milles commented on a change in pull request #1392: fix possible null dereference in staticTypeCheckingVisitor class

eric-milles commented on a change in pull request #1392:
URL: https://github.com/apache/groovy/pull/1392#discussion_r498491178



##########
File path: src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
##########
@@ -2592,7 +2592,7 @@ public void visitStaticMethodCallExpression(final StaticMethodCallExpression cal
             // in that order
             List<Receiver<String>> receivers = new LinkedList<>();
             addReceivers(receivers, makeOwnerList(new ClassExpression(receiver)), false);
-            List<MethodNode> mn = null;
+            List<MethodNode> mn = Collections.emptyList();
             Receiver<String> chosenReceiver = null;
             for (Receiver<String> currentReceiver : receivers) {
                 mn = findMethod(currentReceiver.getType(), name, args);

Review comment:
       Is it possible for `receivers` to be empty?  If not, `mn` is always initialized.  Setting to `null` stops compiler from saying we use an uninitialized variable.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org