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

"java.nio.file.Path.setText" does not work with CompileStatic on Groovy 2.5.7

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 2.5.7
    • Fix Version/s: 2.5.8, 3.0.0-beta-2
    • Component/s: Static compilation
    • Labels:
      None
    • Environment:
      Linux. Java 11.

      Description

      Code like the following will not work correctly on Groovy 2.5.7 with @CompileStatic enabled (groovy-nio required):

      Files.createTempFile('will not', 'compile').text = 'Some Text'

      On Groovy 2.5.7 it compiles as

      String var1 = "Some Text";
      NioGroovyMethods.getText(Files.createTempFile("will not", "compile"));

      whereas Groovy 2.5.6 it compiled as

      String var1 = "Some Text";
      ScriptBytecodeAdapter.setProperty(var1, (Class)null, Files.createTempFile("will not", "compile"), (String)"text");

      The latter is working, the former is not.

      Calling Path.setText should call the setter and not the getter for property text when compiling statically!

      Attached is a sample project demonstrating the issue.

        Attachments

        Issue Links

          Activity

            People

            • Assignee:
              daniel_sun Daniel Sun
              Reporter:
              jhunovis Jan Hackel

              Dates

              • Created:
                Updated:
                Resolved:

                Issue deployment