You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Damir Murat (Jira)" <ji...@apache.org> on 2020/12/24 20:01:00 UTC

[jira] [Updated] (GROOVY-9858) In generated closures, annotate generated call() methods with @Generated

     [ https://issues.apache.org/jira/browse/GROOVY-9858?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Damir Murat updated GROOVY-9858:
--------------------------------
    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.


  was:
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 appear in the coverage report, while the "doCall()", which contains the implementation of a closure body, will be reported as covered.



> In generated closures, annotate generated call() methods with @Generated
> ------------------------------------------------------------------------
>
>                 Key: GROOVY-9858
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9858
>             Project: Groovy
>          Issue Type: Improvement
>          Components: Compiler
>    Affects Versions: 3.0.7
>            Reporter: Damir Murat
>            Priority: Minor
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> 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.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)