Bug 264797

Summary: Can't open overriden enum method.
Product: [Eclipse Project] JDT Reporter: Brian Miller <Brian.Miller>
Component: CoreAssignee: Srikanth Sankaran <srikanth_sankaran>
Status: VERIFIED INVALID QA Contact:
Severity: normal    
Priority: P3 CC: amj87.iitr, daniel_megert, markus.kell.r, srikanth_sankaran
Version: 3.5   
Target Milestone: 3.7 M2   
Hardware: All   
OS: All   
Whiteboard:

Description Brian Miller CLA 2009-02-12 21:17:01 EST
Build ID: I20090202-1535

Steps To Reproduce:
1. Place the caret in identifier 'bar' on LINE 11.
2. Press F3 (Open Declaration).  See that the wrong method is opened.  It should open X.bar() instead of E.bar().

More information:
------------- Bug.java ---------------
class Bug{
	enum E{
		X{
			@Override
			void bar(){
			}};
		void bar(){}
	}
	void foo(){
		E.X.
		bar //LINE 11
		();
	}
}
Comment 1 Dani Megert CLA 2009-02-13 04:11:15 EST
Looks like a bug when resolving the element.
Comment 2 Markus Keller CLA 2009-02-13 05:41:56 EST
Looks correct to me.

The type of 'E.X' in 'E.X.bar()' is E, not the anonymous type. This becomes more clear if you change 'void bar(){}' in X to 'void bar2(){}' and then try to invoke 'E.X.bar2()' from outside. javac agrees with us that bar2() is not visible.
Comment 3 Srikanth Sankaran CLA 2010-08-23 00:29:39 EDT
(In reply to comment #2)
> Looks correct to me.
> 
> The type of 'E.X' in 'E.X.bar()' is E, not the anonymous type. This becomes
> more clear if you change 'void bar(){}' in X to 'void bar2(){}' and then try to
> invoke 'E.X.bar2()' from outside. javac agrees with us that bar2() is not
> visible.

Yes.

cf.

public class Bug {
static class E {
    public static final E X = new E() { void bar() {}};
    void bar(){}
    }
    void foo(){
        E.X.bar();
    }
}
Comment 4 Ayushman Jain CLA 2010-09-13 08:22:26 EDT
Verified for 3.7M2.