Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 357952

Summary: Ajc refuses @Override on a "normal" implementation in presence of ITD one
Product: [Tools] AspectJ Reporter: Roman Shevchenko <trespasserw>
Component: CompilerAssignee: aspectj inbox <aspectj-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3 CC: aclement, michlz
Version: 1.6.12   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Roman Shevchenko CLA 2011-09-16 10:55:15 EDT
In a following code:

public aspect ATest {
    public static interface I {
        void m();
        void g();
    }

    public void I.m() { }

    public static class Impl implements I {
        @Override
        public void m() { } // error: The method m() of type ATest.Impl must override or implement a supertype method

        @Override
        public void g() { }  // ok
    }
}
Comment 1 Andrew Clement CLA 2011-09-16 16:09:44 EDT
It isn't totally clear that this is a bug.  The m() you have ITD'd onto I is the 'default implementation' of m() - it doesn't really exist on I as a real method.  From that point of view the @Override variant of m() is not actually overriding an implementation from the supertype.  I can see what you are saying though, it almost feels like it is an override.
Comment 2 Roman Shevchenko CLA 2011-09-25 03:35:04 EDT
I mean that an introduction of the inter-typed m() breaks a plain Java inheritance flow. In the given example I would like to think of Implement.m() overriding it's declaration in the interface - not the added method.
Comment 3 Kirsten M. Z. CLA 2013-07-24 07:01:18 EDT
Eclipse works with the following code for a long time now:

    public interface I {
        void m();
    }

    public class Impl implements I {
        @Override
        public void m() { }
    }

The code completion "Add unimplemented methods" (in absence of method m() in Impl) even includes the method with annotation "@Override".

Therefore, I assume that "@Override" is expected right there and the initial report is showing a bug.