Reputation: 2831
So I have the following case:
trait JsonRepresentable {
def foo() { print "json" }
}
class SuperA implements JsonRepresentable { }
class SuperB implements JsonRepresentable { }
class Child1 extends SuperA {}
class Child2 extends SuperB { }
Now, if I call the foo() method on SuperA or SuperB it works fine. However if I inherit from them the foo() method is not implemented on the child classes.
Groovy:Can't have an abstract method in a non-abstract class. The class 'Child1' must be declared abstract or the method 'foo()' must be implemented.
It can be solved if I implement the JsonRepresentable trait on the child too, but its already defined on the super class so I guess there is a way to inherit the trait's foo method some way. Can you help me how to do that?
Edit: Groovy version: 2.3.10
Upvotes: 2
Views: 1235
Reputation: 2831
The problem was not in groovy. It was the eclipse groovy plugin (or compiler) which marked the build erroneously. I couldn't solve the compilation issue, but it runs fine when I start the application, so it's ok with me.
Upvotes: 3