Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-9153

StaticInvocationWriter modifies shared global node ConstantExpression.NULL

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.5.8, 3.0.0-beta-2
    • Component/s: None
    • Labels:
      None

      Description

      In the case of a static groovy method call like File.createTempDir() when @CompileStatic is applied, StaticInvocationWriter's writeDirectMethodCall and loadArguments mutate the shared global constant node ConstantExpression.NULL.

      Relevant bits:

          protected boolean writeDirectMethodCall(final MethodNode target, final boolean implicitThis, final Expression receiver, final TupleExpression args) {
              ...
              if (target instanceof ExtensionMethodNode) {
                  ...
                  if (emn.isStaticExtension()) {
                      // it's a static extension method
                      argumentList.add(0, ConstantExpression.NULL);
                  } else {
                      ....
                  }
      
                  Parameter[] parameters = node.getParameters();
                  loadArguments(argumentList, parameters);
      ...
          protected void loadArguments(List<Expression> argumentList, Parameter[] para) {
              ...
                      // This is repeated 3 times in the method:
                      Expression expression = argumentList.get(i);
                      expression.putNodeMetaData(PARAMETER_TYPE, para[i].getType());
      

        Attachments

        1. ConstantExpression.java
          7 kB
          Eric Milles

          Issue Links

            Activity

              People

              • Assignee:
                daniel_sun Daniel Sun
                Reporter:
                emilles Eric Milles
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 0.5h
                  0.5h