You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2020/10/03 06:52:28 UTC

[groovy] branch master updated: fail fast instead of currently redundant null check (closes #1392)

This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/master by this push:
     new 146f06b  fail fast instead of currently redundant null check (closes #1392)
146f06b is described below

commit 146f06bda613c8eb897a7b42e906e8f4bbe05c7f
Author: Paul King <pa...@asert.com.au>
AuthorDate: Sat Oct 3 16:52:19 2020 +1000

    fail fast instead of currently redundant null check (closes #1392)
---
 .../org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
index 0c244e8..e36cf53 100644
--- 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,10 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport {
                     break;
                 }
             }
-            if (mn == null || mn.isEmpty()) {
+            if (mn == null) {
+                throw new GroovyBugError("Invalid state finding valid method: receivers should never be empty and findMethod should never return null");
+            }
+            if (mn.isEmpty()) {
                 mn = extension.handleMissingMethod(receiver, name, argumentList, args, call);
             }
             boolean callArgsVisited = false;