private void visitOverride(AnnotatedNode node, AnnotationNode visited) {
        ClassNode annotationClassNode = visited.getClassNode();
        if (annotationClassNode.isResolved() && annotationClassNode.getName().equals("java.lang.Override")) {
            if (node instanceof MethodNode && !Boolean.TRUE.equals(node.getNodeMetaData(Verifier.DEFAULT_PARAMETER_GENERATED))) {
                boolean override = false;
                MethodNode origMethod = (MethodNode) node;
                ClassNode cNode = origMethod.getDeclaringClass();
                if (origMethod.hasDefaultValue()) {
                    List<MethodNode> variants = cNode.getDeclaredMethods(origMethod.getName());
                    for (MethodNode m : variants) {
                        if (m.getAnnotations().contains(visited) && isOverrideMethod(m)) {
                            override = true;
                            break;
                        }
                    }
                } else {
                    override = isOverrideMethod(origMethod);
                }

                if (!override) {
                    addError("Method '" + origMethod.getName() + "' from class '" + cNode.getName() + "' does not override " +
                            "method from its superclass or interfaces but is annotated with @Override.", visited);
                }
            }
        }
    }
private void visitOverride ( AnnotatedNode node , AnnotationNode visited ) { ClassNode annotationClassNode = visited . getClassNode ( ) ; if ( annotationClassNode . isResolved ( ) && annotationClassNode . getName ( ) . equals ( "java.lang.Override" ) ) { if ( node instanceof MethodNode && ! Boolean . TRUE . equals ( node . getNodeMetaData ( Verifier . DEFAULT_PARAMETER_GENERATED ) ) ) { boolean override = false ; MethodNode origMethod = ( MethodNode ) node ; ClassNode cNode = origMethod . getDeclaringClass ( ) ; if ( origMethod . hasDefaultValue ( ) ) { List < MethodNode > variants = cNode . getDeclaredMethods ( origMethod . getName ( ) ) ; for ( MethodNode m : variants ) { if ( m . getAnnotations ( ) . contains ( visited ) && isOverrideMethod ( m ) ) { override = true ; break ; } } } else { override = isOverrideMethod ( origMethod ) ; } if ( ! override ) { addError ( "Method '" + origMethod . getName ( ) + "' from class '" + cNode . getName ( ) + "' does not override " + "method from its superclass or interfaces but is annotated with @Override." , visited ) ; } } } }
TODO GROOVY-5011 handle case of @Override on a property