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

@Newify AST transformation doesn't work for closure

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.2.0-rc-3
    • 2.2.1
    • None
    • 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

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: