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

In generated closures, annotate generated call() methods with @Generated

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.0.7
    • 2.5.15, 3.0.8, 4.0.0-alpha-3
    • Compiler
    • None

    Description

      Closures generated by the Groovy compiler contain both "doCall()" and "call()" methods, where "call()" always delegate to the "doCall()".

      Typically, users will use a short form of closure invocation, which Groovy translates to direct call of "doCall()". This means that the generated "call()" method will never get invoked in a typical scenario.

      When using JaCoCo for code coverage, it will report the "call()" method as unused.

      For these reasons, it looks sensible to annotate all generated "call()" methods with "@Generated". That way "call()" method will not appear in the coverage report, while the "doCall()", which contains the implementation of a closure body, will be reported as covered.

      Attachments

        Activity

          People

            paulk Paul King
            dmurat Damir Murat
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 0.5h
                0.5h