We have recently merged a PR[1] in Grails that adds the
groovy.transform.Generated annotation to all Trait methods so that
they do not screw up test coverage statistics when they are added to
implementing classes.

I noticed that the PR also added the annotation to private methods in
the Traits and I am curious if this is necessary?

According to AI:
> A private method in a Groovy Trait is trait-private: it’s compiled into the 
> trait’s helper class and used only by other methods in the trait. It is not 
> added to (or visible on) the implementing class, so you can’t call it from 
> the class (or from other traits).

> A trait-private method is already an internal implementation detail and won’t 
> be added to or visible on implementing classes. Annotating it with @Generated 
> doesn’t change semantics or visibility.

Thanks for any wisdom on this!
/Mattias

[1] https://github.com/apache/grails-core/pull/15150

Reply via email to