Community
Participate
Working Groups
Eclipse compiler compiles that code without an error where it should report an error because the method foo() exists for both bounds with a different return type. interface I { String foo(); } class A { public Object foo() { return null; } } public class X<T extends A&I> { } javac reports: X.java:11: foo() in A cannot implement foo() in I; attempting to use incompatible return type found : java.lang.Object required: java.lang.String
Same problem when the two bounds are interfaces. interface I { Float foo(); } interface J { Integer foo(); } public class X<T extends J&I> { } javac reports in this case: X.java:9: types I and J are incompatible; both define foo(), but with unrelated return types public class X<T extends J&I> { If you replace Integer with Object, it compiles fine.
Added MethodVerify test032 NOTE: javac only reports these errors when the problem type follows the bounds if the type X is defined first, then no errors are reported
Verified in I20050215-2300