Description
The mixin keyword should look, from the parser, like a class declaration. The only difference is you create a MixinNode rather than a ClassNode in the AST.
mixin Foo {
private x
bar()
{ return "hello" }}
A MixinNode is-a ClassNode.
The other part of this fix is that a normal class declaration needs to be able to specify one or more mixins which apply to the class.
We could just use the mixins inside a normal 'implements' syntax.
class X extends SomeBaseClass implements Foo, SomeOtherMixin, Someinterface {
}
Basically at runtime the Mixin gets compiled down to a Java interface, so in Java-land a mixin is an interface which you can cast to & use. Though the implementation code of the mixin gets copied into the class to implement the interface.
At the AST level a mixin is different to an interface (they are separated on the ClassNode constructor). I wonder if the compiler can detect the MixinNode in the implements list and pass this directly into the AST?
Attachments
Issue Links
- is depended upon by
-
GROOVY-753 complete parser
- Closed