You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2026/07/04 11:16:07 UTC

(groovy) branch master updated: Trivial refactor: use pattern variable instead

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

asf-gitbox-commits 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 4fe0502395 Trivial refactor: use pattern variable instead
4fe0502395 is described below

commit 4fe05023952638c41d47fee60937d237c558aceb
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sat Jul 4 20:15:52 2026 +0900

    Trivial refactor: use pattern variable instead
---
 src/main/java/groovy/lang/Closure.java                    | 3 +--
 src/main/java/org/codehaus/groovy/ast/query/AstQuery.java | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/main/java/groovy/lang/Closure.java b/src/main/java/groovy/lang/Closure.java
index 7679ddf019..d559bc55a8 100644
--- a/src/main/java/groovy/lang/Closure.java
+++ b/src/main/java/groovy/lang/Closure.java
@@ -1352,8 +1352,7 @@ public abstract class Closure<V> extends GroovyObjectSupport implements Cloneabl
             grey.add(node);
             stack.push(new Marker(node));
             for (final Object link : new Object[]{node.owner, node.delegate, node.thisObject}) {
-                if (link instanceof Closure) {
-                    final Closure<?> child = (Closure<?>) link;
+                if (link instanceof Closure<?> child) {
                     if (grey.contains(child)) {
                         throw new InvalidObjectException(
                                 "Closure owner/delegate/thisObject references form a cycle; refusing to deserialize");
diff --git a/src/main/java/org/codehaus/groovy/ast/query/AstQuery.java b/src/main/java/org/codehaus/groovy/ast/query/AstQuery.java
index 9a6a2eb5a3..6fc8e0400e 100644
--- a/src/main/java/org/codehaus/groovy/ast/query/AstQuery.java
+++ b/src/main/java/org/codehaus/groovy/ast/query/AstQuery.java
@@ -355,8 +355,7 @@ public final class AstQuery<T extends ASTNode> {
                 visitField((FieldNode) node);
             } else if (node instanceof PropertyNode) {
                 visitProperty((PropertyNode) node);
-            } else if (node instanceof ModuleNode) {
-                ModuleNode module = (ModuleNode) node;
+            } else if (node instanceof ModuleNode module) {
                 for (ClassNode cn : module.getClasses()) {
                     if (!(cn instanceof InnerClassNode)) visitClass(cn);
                 }