You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by sh...@apache.org on 2015/12/05 06:45:14 UTC

groovy git commit: GROOVY-7694 Results of spread safe method calls should be stored in temporary variables Closes #200

Repository: groovy
Updated Branches:
  refs/heads/master 6c0320bb5 -> 0c87feee9


GROOVY-7694 Results of spread safe method calls should be stored in temporary variables
Closes #200


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/0c87feee
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/0c87feee
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/0c87feee

Branch: refs/heads/master
Commit: 0c87feee903a9ffd75f6a10101ac470478af286d
Parents: 6c0320b
Author: Shil Sinha <sh...@apache.org>
Authored: Mon Nov 30 13:36:57 2015 -0500
Committer: Shil Sinha <sh...@apache.org>
Committed: Sat Dec 5 00:44:29 2015 -0500

----------------------------------------------------------------------
 .../classgen/asm/sc/StaticInvocationWriter.java      | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/0c87feee/src/main/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java b/src/main/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java
index b9f65a2..963ba74 100644
--- a/src/main/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java
+++ b/src/main/org/codehaus/groovy/classgen/asm/sc/StaticInvocationWriter.java
@@ -458,19 +458,11 @@ public class StaticInvocationWriter extends InvocationWriter {
             ClassNode classNode = controller.getClassNode();
             int counter = labelCounter.incrementAndGet();
 
-            // create an empty arraylist
-            VariableExpression result = new VariableExpression(
-                    "spreadresult" + counter,
-                    StaticCompilationVisitor.ARRAYLIST_CLASSNODE
-            );
+            // use a temporary variable for the arraylist in which the results of the spread call will be stored
             ConstructorCallExpression cce = new ConstructorCallExpression(StaticCompilationVisitor.ARRAYLIST_CLASSNODE, ArgumentListExpression.EMPTY_ARGUMENTS);
             cce.setNodeMetaData(StaticTypesMarker.DIRECT_METHOD_CALL_TARGET, StaticCompilationVisitor.ARRAYLIST_CONSTRUCTOR);
-            DeclarationExpression declr = new DeclarationExpression(
-                    result,
-                    Token.newSymbol("=", origin.getLineNumber(), origin.getColumnNumber()),
-                    cce
-            );
-            declr.visit(controller.getAcg());
+            TemporaryVariableExpression result = new TemporaryVariableExpression(cce);
+            result.visit(controller.getAcg());
             operandStack.pop();
             // if (receiver != null)
             tmpReceiver.visit(controller.getAcg());
@@ -516,6 +508,7 @@ public class StaticInvocationWriter extends InvocationWriter {
             if (tmpReceiver instanceof TemporaryVariableExpression) {
                 ((TemporaryVariableExpression) tmpReceiver).remove(controller);
             }
+            result.remove(controller);
         } else if (safe && origin instanceof MethodCallExpression) {
             // wrap call in an IFNULL check
             MethodVisitor mv = controller.getMethodVisitor();