Details
-
Bug
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
None
-
None
-
None
Description
I have the following program
import java.util.*; import java.util.function.*; class A<T> { void m(T x) { System.out.println("there"); } void m(Integer x) { System.out.println("here"); } } class Test { public static void main(String[] args) { A<Integer> x = new A<>(); Consumer<Integer> y = x::m; y.accept(1) } }
Actual behavior
Depending on the order in which methods "m()" appear in the program, the outcome is different. So, if "m( T x)" is first, the outcome is "there". Otherwise, if "m( Integer x)" is first, the outcome is "here".
Expected behavior
I would expect that the reference "x::m" is ambiguous, so the program should have been rejected.
Tested against master (commit: d3c07b8416743545ebb81fda43768f2cec4ca59b)