[ https://issues.apache.org/jira/browse/GROOVY-8859?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17765031#comment-17765031 ]
Jochen Theodorou commented on GROOVY-8859: ------------------------------------------ For me option 2 is good > traits allow access to private fields and static methods but not instance > methods > --------------------------------------------------------------------------------- > > Key: GROOVY-8859 > URL: https://issues.apache.org/jira/browse/GROOVY-8859 > Project: Groovy > Issue Type: Question > Components: Compiler > Reporter: Eric Milles > Assignee: Eric Milles > Priority: Minor > Labels: trait, traits > > It seems that private in a trait is akin to protected in a class. For > example a class that implements a trait may access private fields (through > namespace syntax) and properties and call private static methods. And it may > use Type.super.method() to disambiguate methods if necessary. *Why, however, > can a class that implements a trait not call private instance methods?* This > is not really covered in the language specification. > {code:groovy} > trait T { > private void privit() { > println 'private' > } > public void publik() { > println 'public' > } > } > class C implements T { > def m() { > publik() > privit() > } > } > new C().m() > {code} > This fails with missing method. But if static modifier is added to privit, > it succeeds. -- This message was sent by Atlassian Jira (v8.20.10#820010)