Bug 226151 - [search] constructor declaration match reported as synthetic method reference
Summary: [search] constructor declaration match reported as synthetic method reference
Status: CLOSED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks: 27236 182346
  Show dependency tree
 
Reported: 2008-04-08 12:37 EDT by Markus Keller CLA
Modified: 2020-03-09 15:36 EDT (History)
2 users (show)

See Also:


Attachments
Proposed patch (5.07 KB, patch)
2010-07-29 04:48 EDT, Satyam Kandula CLA
no flags Details | Diff
Proposed patch (2.04 KB, patch)
2011-03-17 10:40 EDT, Satyam Kandula CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2008-04-08 12:37:04 EDT
I20080401-0851
(I'm trying to remove ugly old workarounds for bug 27236 to get a reasonable fix for bug 182346).

package m;
class A{
	A(){
	}
}
class B extends A{
	B(){
	}
	void m() {
	    new A();
	}
}

Search for occurrences of constructor A().

Results:
- MethodReferenceMatch on A() (synthetic)
=> wrong, should be MethodDeclarationMatch
- MethodReferenceMatch on B() (synthetic) => correct
- MethodReferenceMatch on new A() => correct

The problem is that ConstructorLocator.newDeclarationMatch(..) creates reference matches and that
        boolean synthetic = call != null && call.isImplicitSuper();
is wrong in this case. Note that the same method is also used to create the correct MethodReferenceMatch on B(), so just changing
	if (this.pattern.findReferences) {
into
	if (this.pattern.findReferences && !this.pattern.findDeclarations) {
will not work.
Comment 1 Markus Keller CLA 2008-04-09 13:50:19 EDT
This bug is blocking my progress on bug 182346. Would it be possible to handle it as P2?

As a workaround, I tried to replace the ALL_OCCURRENCES search pattern by an OR pattern from a REFERENCES and a DECLARATIONS pattern. But that didn't give me any match for B any more in the following example:

enum A_testEnum02_in {
    A(1), B(2) { }
   	;
   	A_testEnum02_in(int i) { }
}
Comment 2 Satyam Kandula CLA 2010-07-29 04:48:19 EDT
Created attachment 175458 [details]
Proposed patch

Markus, Can you try this patch and let me know if it is good for you.
Comment 3 Satyam Kandula CLA 2011-03-17 10:40:22 EDT
Created attachment 191426 [details]
Proposed patch

Updated the patch with HEAD. Modified the test too.
Comment 4 Eclipse Genie CLA 2020-03-09 15:36:29 EDT
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. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. 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.