Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 209634

Summary: [DOM] Equal but not identical method bindings with inferred type arguments
Product: [Eclipse Project] JDT Reporter: Markus Keller <markus.kell.r>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: minor    
Priority: P3 CC: frederic_fusier, kent_johnson, philippe_mulet
Version: 3.4   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: stalebug

Description Markus Keller CLA 2007-11-13 09:59:39 EST
HEAD

import java.util.Collections;
import java.util.List;

public class Try {
	List<String> get(boolean b) {
		if (b)
			return Collections.<String>emptyList();
		else
			return Collections.emptyList();
	}
}

The two IMethodBindings for emptyList() are isEqualTo(..) each other and their keys are the same, but the bindings are not identical.
Comment 1 Olivier Thomann CLA 2008-07-14 14:54:40 EDT
The compiler creates two different instances of ParameterizedMethodBinding in this case. Since this class doesn't define an equals method, the first IMethodBinding is not returned from the hash map that contains the compiler<->dom binding mapping when the second IMethodBinding is requested.
Kent, Philippe, is is doable to reuse the same binding on the compiler side?

If not, we either don't support identity for method bindings or I change the way to mapping is done for parameterized method binding.
Comment 2 Philipe Mulet CLA 2008-07-15 07:25:50 EDT
In this example, the first method is inferred to be:
Collections.<String>emptyList()

where the second invocation ends up inferring 
Collections.<Object>emptyList()

(from checking the hover/codeselect).

This would explain different bindings.
Comment 3 Philipe Mulet CLA 2008-07-15 07:59:36 EDT
Actually, my previous comment is rather a bug in the hover/select support. When debugging the compiler, I can see that the compiler is doing proper inference that T==String, but indeed it constructs a different method binding than in the first situation. 
Comment 4 Markus Keller CLA 2008-07-15 08:08:06 EDT
The problem with codeSelect is bug 209639. This bug is about binding identity.
Comment 5 Eclipse Genie CLA 2019-09-15 19:08:09 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.

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.