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

Seems to be a gap in method reference support

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 4.0.0-alpha-1, 3.0.6
    • None
    • None

    Description

      With the class definition, it appears to produce the correct output:

      @groovy.transform.CompileStatic
      class Foo {
        static void main(args) {
          Function<String, String> lower = String::toLowerCase
          println "lower = $lower" // => Foo$$Lambda$14/0x0000000801205040@7bd4937b
        }
      }
      

      Removing to make it a script method gives:

      @groovy.transform.CompileStatic
      //class Foo {
        static void main(args) {
          Function<String, String> lower = String::toLowerCase
          println "lower = $lower" // => org.codehaus.groovy.runtime.MethodClosure@4cdd2c73
        }
      //}
      

      I don't know whether it is a gap in method reference handling or does the @CompileStatic annotation get lost on the special script main method when we override. Still to be investigate but we either need to fix or document.

      Attachments

        Activity

          People

            paulk Paul King
            paulk Paul King
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: