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

Bug 405141

Summary: [assist] Completion engine should disambiguate ambiguous field access through multiply inherited interfaces
Product: [Eclipse Project] JDT Reporter: ANIRBAN CHAKRABORTY <anchakrk>
Component: CoreAssignee: ANIRBAN CHAKRABORTY <anchakrk>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: anchakrk, srikanth_sankaran
Version: 4.3   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard: stalebug
Attachments:
Description Flags
Patch for the fix anchakrk: review?

Description ANIRBAN CHAKRABORTY CLA 2013-04-08 06:25:26 EDT
public interface Foo { 
	int run1(int s1, int s2);
	static int x2 = 0;
}

interface AnotherFoo { 
	int run1(int s1, int s2);
	static int x2 = 0;
}


interface X extends Foo, AnotherFoo{
	
    static Foo f = (x5, x6) -> x<ctrl-space>
    		
}

Here both Foo.x2 and AnotherFoo.x2 are suggested. But when you select them, for one, only x2 is printed. For other X.x2 is getting printed. Both cases give compiler error as ambiguous x2.

Thanks
Anirban
Comment 1 ANIRBAN CHAKRABORTY CLA 2013-07-17 08:55:25 EDT
Created attachment 233551 [details]
Patch for the fix

Patch for the fix
Comment 2 Srikanth Sankaran CLA 2013-07-22 02:50:24 EDT
(1) With the patch applied, I get an NPE when completing below:

interface Foo { 
	int run1(int s1, int s2);
	static int x2 = 0;
}

interface AnotherFoo { 
	int run1(int s1, int s2);
	static int x2 = 0;
}


interface X extends Foo, AnotherFoo{
	
	int x = x
  // static Foo f = (x5, x6) -> x
	int y = x|
    		
}

(2) Why is it OK to not do the disambiguation when findFields is called
through 
findFieldsAndMethods(char[], TypeBinding, Scope, ObjectVector, ObjectVector, InvocationSite, Scope, boolean, boolean, Binding[], int[], int[], boolean, char[], int, int)
findFieldsAndMethodsFromStaticImports(char[], Scope, InvocationSite, Scope, boolean, boolean, ObjectVector, ObjectVector, ObjectVector, boolean, boolean)
findMembers(char[], ReferenceBinding, Scope, InvocationSite, boolean, Binding[], int[], int[], boolean)
Comment 3 Srikanth Sankaran CLA 2013-11-11 00:15:02 EST
The review comments have been unattended to for nearly 4 months now. Please
take a look,
Comment 4 Srikanth Sankaran CLA 2013-11-25 07:57:00 EST
This is not a Java 8 issue. Nor or the proposals incorrect, though we could
upfront offer suitably qualified proposals to disambiguate. Resetting target.
Comment 5 Srikanth Sankaran CLA 2013-11-25 07:57:45 EST
See that same problem exists without lambda:

// --
interface Foo { 
	int run1(int s1, int s2);
	static int x2 = 0;
}

interface AnotherFoo { 
	int run1(int s1, int s2);
	static int x2 = 0;
}


interface X extends Foo, AnotherFoo{
	
    static int x = x|
    		
}
Comment 6 Eclipse Genie CLA 2020-03-03 17:20:21 EST
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.