eclipse-jdt / eclipse-jdt/eclipse.jdt.core
ECJ admits super call to unrelated method
- Dominant language
- Java
- Stars
- 237
- Forks
- 195
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 47
Description
Reduced example from https://bugs.eclipse.org/bugs/show_bug.cgi?id=412447
```java
class A {}
class B extends A {}
class C extends B {}
abstract class Test1 {
abstract void foo(T1 param1);
}
abstract class Test2 extends Test1 {
@Override
void foo(B param2) { }
}
public class Test3 extends Test2 {
@Override
void foo(C param3) {
super.foo(param3);
}
}
```
javac reports:
```
Test3.java:17: error: abstract method foo(T1) in Test1 cannot be accessed directly
super.foo(param3);
^
where T1 is a type-variable:
T1 extends A declared in class Test1
```
ecj, however, accepts and generates indeed a call to Test2.foo(B).
There is something weird about the program:
* Test2.foo(B) claims to override Test1.foo(T1) _(both compiler accept the `@Override` annotation)_
* here Test1.foo(T1) is instantiated to Test1.foo(T2)
* Test3.foo(C) does not override Test2.foo(B) _(no type variables to be instantiated here)_
* Test3 inherits Test1.foo(T1) as Test1.foo(C), which would be applicable but is abstract!
I'm still not sure about the override in Test2: as soon as T2 is instantiated to C, then Test2.foo(B) no longer overrides Test1.foo() instantiated as Test1.foo(C).
Key-question: which method should overload resolution pick
* Test1.foo(C) is more specific than Test2.foo(B)
* but Test2.foo(B) claims to override the other one!
TODO: check if the phrase "overrides from C" used in JLS §8.4.8.1 indeed admits different perspective, so there could be an override "from Test2" but no override "from Test3"...
Contributor guide
Assessment
This issue has not been assessed yet.