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 2025/01/18 10:38:14 UTC

(groovy) branch GROOVY_4_0_X updated: Trivial refactoring: extract constant

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

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


The following commit(s) were added to refs/heads/GROOVY_4_0_X by this push:
     new 8ac24b0dc1 Trivial refactoring: extract constant
8ac24b0dc1 is described below

commit 8ac24b0dc1b87317de4aa504b10d734821645c98
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sat Jan 18 19:38:01 2025 +0900

    Trivial refactoring: extract constant
---
 .../codehaus/groovy/classgen/asm/sc/StaticTypesLambdaWriter.java | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesLambdaWriter.java b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesLambdaWriter.java
index 9a8d3e9686..17c0028520 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesLambdaWriter.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesLambdaWriter.java
@@ -85,6 +85,7 @@ public class StaticTypesLambdaWriter extends LambdaWriter implements AbstractFun
 
     private static final String IS_GENERATED_CONSTRUCTOR = "__IS_GENERATED_CONSTRUCTOR";
     private static final String LAMBDA_SHARED_VARIABLES = "__LAMBDA_SHARED_VARIABLES";
+    private static final String DO_CALL = "doCall";
 
     private final StaticTypesClosureWriter staticTypesClosureWriter;
     private final Map<Expression, ClassNode> lambdaClassNodes = new HashMap<>();
@@ -116,7 +117,7 @@ public class StaticTypesLambdaWriter extends LambdaWriter implements AbstractFun
         int modifiers = ACC_FINAL | ACC_PUBLIC;
         if (enclosingClass.isInterface()) modifiers |= ACC_STATIC;
         ClassNode lambdaClass = getOrAddLambdaClass(expression, modifiers, abstractMethod);
-        MethodNode lambdaMethod = lambdaClass.getMethods("doCall").get(0);
+        MethodNode lambdaMethod = lambdaClass.getMethods(DO_CALL).get(0);
 
         boolean canDeserialize = enclosingClass.hasMethod(createDeserializeLambdaMethodName(lambdaClass), createDeserializeLambdaMethodParams());
         if (!canDeserialize) {
@@ -212,8 +213,8 @@ public class StaticTypesLambdaWriter extends LambdaWriter implements AbstractFun
     }
 
     private ClassNode getOrAddLambdaClass(final LambdaExpression expression, final int modifiers, final MethodNode abstractMethod) {
-        return lambdaClassNodes.computeIfAbsent(expression, key -> {
-            ClassNode lambdaClass = createLambdaClass(expression, modifiers, abstractMethod);
+        return lambdaClassNodes.computeIfAbsent(expression, expr -> {
+            ClassNode lambdaClass = createLambdaClass((LambdaExpression) expr, modifiers, abstractMethod);
             controller.getAcg().addInnerClass(lambdaClass);
             lambdaClass.addInterface(GENERATED_LAMBDA_TYPE);
             lambdaClass.putNodeMetaData(StaticCompilationMetadataKeys.STATIC_COMPILE_NODE, Boolean.TRUE);
@@ -278,7 +279,7 @@ public class StaticTypesLambdaWriter extends LambdaWriter implements AbstractFun
         expression.putNodeMetaData(LAMBDA_SHARED_VARIABLES, localVariableParameters);
 
         MethodNode doCallMethod = lambdaClass.addMethod(
-                "doCall",
+            DO_CALL,
                 ACC_PUBLIC,
                 abstractMethod.getReturnType(),
                 parametersWithExactType.clone(),