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

@Newify AST transformation doesn't work for closure

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.0-rc-3
    • Fix Version/s: 2.2.1
    • Component/s: None
    • Labels:
      None

      Description

      This code:

      @Newify([String])
      String test1() {
          return String("ABC")
      }
      
      @Newify([String])
      String test2() {
          return { -> String("ABC") }.call()
      }
      
      assert "ABC"==test1()
      assert "ABC"==test2()
      
      

      results in:

      Caught: groovy.lang.MissingMethodException: No signature of method: x.String() is applicable for argument types: (java.lang.String) values: [ABC]
      Possible solutions: toString(), toString(), print(java.lang.Object), print(java.lang.Object), print(java.io.PrintWriter), run()
      groovy.lang.MissingMethodException: No signature of method: x.String() is applicable for argument types: (java.lang.String) values: [ABC]
      Possible solutions: toString(), toString(), print(java.lang.Object), print(java.lang.Object), print(java.io.PrintWriter), run()
      at x$_test2_closure1.doCall(x.groovy:9)
      at x.test2(x.groovy:9)
      at x$test2$0.callCurrent(Unknown Source)
      at x.run(x.groovy:13)

      I expect this test2 works as well as test1.

        Attachments

          Activity

            People

            • Assignee:
              paulk Paul King
              Reporter:
              uehaj UEHARA Junji
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: