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

Bug 423803

Summary: [1.8][compiler] No error shown for ambiguous reference to the method
Product: [Eclipse Project] JDT Reporter: Noopur Gupta <noopur_gupta>
Component: CoreAssignee: Srikanth Sankaran <srikanth_sankaran>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, jarthana, markus.kell.r, srikanth_sankaran, stephan.herrmann
Version: 4.4   
Target Milestone: BETA J8   
Hardware: All   
OS: All   
Whiteboard:

Description Noopur Gupta CLA 2013-12-11 08:14:28 EST
package test;

class C2 implements C2_Sup {
    public static final FI fi = x -> x++;
    public static final FL fl = x -> x++;

    {
        bar(x -> x++); // [1]
        bar(fl); 
    }
    void bar(FI fi) { }
}

interface C2_Sup {	
	default void bar(FL fl) { }
}

@FunctionalInterface
interface FI {
	int foo(int x);
}

@FunctionalInterface
interface FL {
    long foo(long x);
}
--------------------------------------------------------

The above example compiles without any error with ECJ, but shows error at [1] with b118.
Comment 1 Srikanth Sankaran CLA 2013-12-11 08:22:13 EST
There are no method references in the program :)

I think this is a duplicate of https://bugs.eclipse.org/bugs/show_bug.cgi?id=422731
Comment 2 Srikanth Sankaran CLA 2013-12-20 06:46:42 EST
So you can work on G related issues without distraction, I'll take over
this one.
Comment 4 Srikanth Sankaran CLA 2014-01-14 03:23:40 EST
(In reply to Srikanth Sankaran from comment #3)
> (Disabled) test released here:
> http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/
> ?h=BETA_JAVA8&id=a17a9082800c426c4984b5ef76877aab1c8e09e6

That was meant for some other bug.

Fix and tests released here: http://git.eclipse.org/c/jdt/eclipse.jdt.core.git/commit/?h=BETA_JAVA8&id=efd527bb42c9215375b4d1cf91326767eee94a32

This is a McWhopper of a bug, thanks for catching it !
Comment 5 Srikanth Sankaran CLA 2014-01-14 03:31:04 EST
*** Bug 422731 has been marked as a duplicate of this bug. ***
Comment 6 Jay Arthanareeswaran CLA 2014-01-14 12:29:26 EST
I initially thought the following was same as the one reported here, but not entirely sure:

class C2 {
    {
        bar( () -> (char) 0); // [1]
    }
    void bar(FC fc) { }
    void bar(FB fb) { }
}

interface FB {
	byte foo();
}
interface FC {
    char foo();
}

This one is accepted by ECJ while Javac rejects.
Comment 7 Stephan Herrmann CLA 2014-01-14 14:24:06 EST
For issues of method ambiguity involving lambdas also see bug 423505
Comment 8 Srikanth Sankaran CLA 2014-01-14 22:40:28 EST
(In reply to Jayaprakash Arthanareeswaran from comment #6)
> I initially thought the following was same as the one reported here, but not
> entirely sure:

Good catch ! This is a different problem, a good one to fix. I have raised:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=425712