groovy - Strange error highlighting 'instance method cannot override the static method' in Eclipse -
assume have such code in groovy:
class base { static string name = 'base'; } class child extends base { string name = 'child'; static main(args){ def ch = new child(); println ch.name; } }
eclipse mars 4.5.2 highlights there error:
this instance method cannot override static method base
i don't override static methods , executes expect, eclipse think wrong?
the error message improved because you're doing here isn't related method (unless eclipse considering methods in generated java), it's related variable. also, groovy doesn't care code works, java wouldn't it.
eclipse letting know defining instance variable in child
has same name static variable in base
.
you should have static modifier in both classes.
class child extends base { static string name = 'child' //... }
Comments
Post a Comment