groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Damir Murat <damir.mu...@gmail.com>
Subject Marking call() method of generated closures with @Generated?
Date Mon, 07 Dec 2020 09:11:05 GMT
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

Mime
View raw message