| Summary: | [search] for declaration/occurrences of method wrongly finds homonym in anonymous class | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Milos Gligoric <milos.gligoric> |
| Component: | Core | Assignee: | JDT-Core-Inbox <jdt-core-inbox> |
| Status: | CLOSED WONTFIX | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | manju656, markus.kell.r |
| Version: | 4.2.1 | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | stalebug | ||
Issue is reproducible using I20121029-2000. The code refactoring results in compiler error. Bug in the search engine, changing subject from "[change method signature] Updates a method in unrelated class which leads to a compilation error".
In ChangeSignatureProcessor.findOccurrences(..) line 1616, we create a search pattern like this:
pattern= RefactoringSearchEngine.createOrPattern(fRippleMethods,
IJavaSearchConstants.ALL_OCCURRENCES);
fRippleMethods are I.m() and ChangeMethodSignatureBug1.new I().m().
The search result wrongly contains "ChangeMethodSignatureBug1.new J().m()" as well. This also happens when I change the pattern to
pattern= SearchPattern.createPattern(fRippleMethods[0],
IJavaSearchConstants.DECLARATIONS, SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE)
, only searching for declarations of the anonymous "new I().m()".
The supertype of the second anonymous also doesn't matter. It even fails here when I search for declarations of "new I().m()":
package p;
class ChangeMethodSignatureBug1 {
void p() {
new I() {
public void m() {
}
};
new Object() {
// This method will also be updated
public void m() {
}
};
}
}
abstract class I {
// Invoke "Change Method Signature" on the method below
abstract void m();
}
=> Looks like there's a missing check whether a candidate method in a anonymous class is really declared in a subtype of the target method.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie. |
Steps to reproduce: 1. See the instructions in code below 2. The resulting code does not compile Build id: 20121114-2344 class ChangeMethodSignatureBug1 { void p() { new I() { public void m() { } }; new J() { // This method will also be updated public void m() { } }; } } interface I { // Invoke "Change Method Signature" on the method below void m(); } interface J { void m(); }