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

Problem with CompileStatic

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.0.1
    • Compiler
    • None

    Description

      The following code compiles with 2.0.0 but not with the current 2.0.1-SNAPSHOT.

      src/main/groovy/com/demo/MyUtility.groovy
      package com.demo
      
      import groovy.transform.CompileStatic
      
      class MyUtility {
          @CompileStatic
          def methodOne() {
              def someFiles = new ArrayList<File>()
              def someString = ''
              methodTwo someString, someFiles
          }
      
          @CompileStatic
          def methodTwo(String s, List<File> files) {}
      }
      

      Extract the attached project and execute the following command to see the error:

      $ ./gradlew clean compileGroovy
      :clean
      :compileJava UP-TO-DATE
      :compileGroovy
      startup failed:
      /Users/jeff/t/compilestatic/src/main/groovy/com/demo/MyUtility.groovy: 10: [Static type checking] - Cannot call com.demo.MyUtility#methodTwo(java.io.File) with arguments [java.lang.String, java.util.ArrayList <File>] 
       @ line 10, column 9.
                 methodTwo someString, someFiles
                 ^
      
      1 error
      
      
      FAILURE: Build failed with an exception.
      
      * What went wrong:
      Execution failed for task ':compileGroovy'.
      > Compilation failed; see the compiler error output for details.
      
      * Try:
      Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
      
      BUILD FAILED
      
      Total time: 3.453 secs
      

      If you edit build.gradle and change 2.0.1-SNAPSHOT to 2.0.0 the code does compile.

      Attachments

        1. compilestatic.zip
          39 kB
          Jeff Brown

        Activity

          People

            melix Cédric Champeau
            brownj Jeff Brown
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: