| Summary: | No compiler error from implementing clashing generic interfaces if implementations of clashing methods are inherited | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Theodore Murdock <theodoremurdock> |
| Component: | Core | Assignee: | Stephan Herrmann <stephan.herrmann> |
| Status: | CLOSED INVALID | QA Contact: | Sasikanth Bharadwaj <sasikanth.bharadwaj> |
| Severity: | normal | ||
| Priority: | P3 | CC: | jarthana, sasikanth.bharadwaj, shankhba, stephan.herrmann |
| Version: | 4.3.2 | ||
| Target Milestone: | 4.13 | ||
| Hardware: | PC | ||
| OS: | Mac OS X | ||
| Whiteboard: | |||
Shankha, please follow up. This is similar to bug 408031, but about inherited methods. Unit test case:
public void testBug456012() {
runConformTest(
new String[] {
"X.java",
"interface I1<F> { public void add(F f); }\n" +
"interface I2<G> { public void add(G g); }\n" +
"class Super {\n" +
" public void add(Integer i) {}\n" +
" public void add(Double s) {}\n" +
"}\n" +
"class MyList extends Super implements I1<Integer>, I2<Double> {}\n" +
"public class X {\n" +
" public static void main(String[] args) {}\n" +
"}\n"});
}
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 code produces no compile error in Eclipse, but (correctly) fails to compile in javac: class MinimalBrokenExample { public static interface I1<F> { public void add(F f); } public static interface I2<G> { public void add(G g); } public static class Super { public void add(Integer i) {} public void add(Double s) {} } public static class MyList extends Super implements I1<Integer>, I2<Double> {} public static void main(String[] args) { ((I1<Integer>) new MyList()).add(0); } } MyList should fail to compile due to a name clash between I1.add() and I2.add() having the same erasure. Instead this compiles without warnings, but casting MyList to I1<Integer> and calling add(0) results in a ClassCastException, because Integer cannot be cast to Double. In the case of clashing inherited implementations of generic interfaces, whichever of the clashing interfaces comes last in the "implements" list wins and works at runtime, the others fail with a ClassCastException. Version information: Kepler SR2, build ID: 20140224-0627 JDT version: 3.9.2.20140114-1555