Bug 56161 - Unexpected compiler error with inner class
Summary: Unexpected compiler error with inner class
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.0 M9   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-03-25 11:11 EST by Dani Megert CLA
Modified: 2004-04-08 09:58 EDT (History)
0 users

See Also:


Attachments
JavaEditor.java (120.15 KB, text/plain)
2004-03-25 11:13 EST, Dani Megert CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dani Megert CLA 2004-03-25 11:11:56 EST
I added the following inner class to JavaEditor.java:

private class EditorSelectionChangedListener extends   
  AbstractSelectionChangedListener {

	public void selectionChanged(SelectionChangedEvent event) {
	  selectionChanged();
	}
}
and protected void selectionChanged() {...} to the class JavaEditor

This gives a compiler error:
The method selectionChanged(SelectionChangedEvent) in the type
JavaEditor.EditorSelectionChangedListener is not applicable for the arguments ()	

Adding JavaEditor.this. in front of selectionChanged() solves it.

Also, pressing F3 on selectionChanged() jumps to
selectionChanged(SelectionChangedEvent event)
Comment 1 Dani Megert CLA 2004-03-25 11:13:40 EST
Created attachment 8880 [details]
JavaEditor.java
Comment 2 Philipe Mulet CLA 2004-04-08 09:58:28 EDT
Reproduced on simplified test case:
class X {
    private class EditorSelectionChangedListener {
        public void selectionChanged(Object event) {
            selectionChanged();
        }
    }
    protected void selectionChanged() {}
}

The compiler error is legite. Method lookups discriminate on arguments amongst 
several matches per selector if these occur on the same method. This is why the 
method #selectionChanged(Object) is picked up, then complained against.
This is what the language spec requires.

You should rename the outer method to avoid collision.

Closing as invalid.