Bug 264797 - Can't open overriden enum method.
Summary: Can't open overriden enum method.
Status: VERIFIED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.7 M2   Edit
Assignee: Srikanth Sankaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-12 21:17 EST by Brian Miller CLA
Modified: 2010-09-13 08:22 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.