Why doesn't the @Override annotation work when creating a Grails project?

I use the Grails 2.3.8 build system to create my Grails project (i.e. the default system built on top of Gant).

When I comment on my methods with @ java.lang.Override, Grails will not compromise compilation, even if the method does not override anything in the parent classes.

When I compile directly with groovyc, everything works fine.

Is there a compilation option that I did not enable? :)

+4
source share
1 answer

Grails 2.3.8 uses Groovy 2.1.9. In this version of Groovy, the @Override annotation fails (at least) in the situation in which I used it (the most basic case):

class A {
        def foo() {}
}


class B extends A {
        @Override
        def foo(String s) {}

}

Groovy (2.1.9) .

Groovy ( , 2.4.1) . , :

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
foo.groovy: 7: Method 'foo' from class 'B' does not override method from its superclass or interfaces but is annotated with @Override.
 @ line 7, column 2.
        @Override
    ^

1 error

: , Groovy 2.1.9 @Override:

  • (, , )
+5

All Articles