You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@groovy.apache.org by Damir Murat <da...@gmail.com> on 2020/12/07 09:11:05 UTC

Marking call() method of generated closures with @Generated?

As far as I understand, closures generated by the Groovy compiler contain
both doCall() and call() methods, where call() always delegate to doCall().

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

When using JaCoCo for code coverage, it will report call() method as unused.
For these reasons, it looks sensible to me to annotate call() with @Generated.
That way call() method will not be in the coverage report, while the doCall(),
which contains the implementation of a closure body, will be reported as covered.

Tnx