@Documented @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) public @interface SelfType
This annotation can be added on a trait to declare the list of types that a class implementing that trait is supposed to extend. This is useful when you want to be able to call methods from the class implementing the trait without having to declare all of them as members of the trait. Self types are particularly useful in combination with CompileStatic, if you know that a trait can only be applied to a specific type but that the trait cannot extend that type itself. For example, imagine the following code:
     class Component { void methodInComponent() }
     trait ComponentDecorator {
         void logAndCall() {
             println "Calling method in component"
             methodInComponent()
         }
         // other useful methods
     }
     class DecoratedComponent extends Component implements ComponentDecorator {}
 
     class Component { void methodInComponent() }
     @CompileStatic
     @SelfType(Component)
     trait ComponentDecorator {
         void logAndCall() {
             println "Calling method in component"
             methodInComponent()
         }
         // other useful methods
     }
     class DecoratedComponent extends Component implements ComponentDecorator {}