Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
None
Description
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.
trait T { private void privit() { println 'private' } public void publik() { println 'public' } } class C implements T { def m() { publik() privit() } } new C().m()
This fails with missing method. But if static modifier is added to privit, it succeeds.
Attachments
Issue Links
- is related to
-
GROOVY-7213 Private methods in traits cause compile time error if the class implementing trait is statically compiled
- Closed