paulk-asert commented on a change in pull request #1392:
URL: https://github.com/apache/groovy/pull/1392#discussion_r498695757



##########
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:
       The other option would be just have an additional null guard for `mn` 
before calling the first `isEmpty`? Saves creating an empty list that we 
believe we will always throw away.
   ```
   --- 
a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
   +++ 
b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
   @@ -2603,7 +2603,7 @@ public class StaticTypeCheckingVisitor extends 
ClassCodeVisitorSupport {
                        break;
                    }
                }
   -            if (mn.isEmpty()) {
   +            if (mn == null || mn.isEmpty()) {
                    mn = extension.handleMissingMethod(receiver, name, 
argumentList, args, call);
                }
                boolean callArgsVisited = false;
   ```




----------------------------------------------------------------
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:
[email protected]


Reply via email to