Community
Participate
Working Groups
Created attachment 274935 [details] Code example that demonstrates the problem. The ejc compiler seems to give priority to methods from class of the reference type when resolving method overloads. The result is that ejc accepts some method calls which should be considered to be ambiguous. This is compared to javac, which rejects these calls. ### Software verions ejc version: I20180710 javac version: 1.8.0_92 Also tested with the same result with JDT 3.13.4, Eclipse Oxygen.3a Release (4.7.3a) Build id: 20180405-1200 ### Output from the compilers Output from the compilers when compiling the example code: $ java -jar ecj-I20180710-2000.jar -classpath rt.jar -source 1.9 OverloadExtensionGenericsBug.java $ $ javac OverloadExtensionGenericsBug.java OverloadExtensionGenericsBug.java:34: error: reference to m is ambiguous b.m(i); // Works in ejc, compile error in javac: Method is ambiguous ^ both method m(T) in A and method m(Integer) in B match where T is a type-variable: T extends Object declared in class A 1 error ### Example code class A<T> { void m(T a) {} void m(Integer a) {} } class B<T> extends A<T> { @Override void m(Integer a) {} // Adding this makes both calls to m result in compile errors // @Override // public void m(T a) { // System.out.println("B#m(T)"); // } } public class OverloadExtensionGenericsBug { public static void main(String[] args) { Integer i = 0; B<Integer> b = new B<>(); b.m(i); // Works in ejc, compile error in javac: Method is ambiguous // A<Integer> a = b; // a.m(i); // Compile error in both ejc and javac: Method is ambiguous } }
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.
This problem still occurs in Eclipse 2022-03 (4.23) Build id: I20211223-1800.