eclipse-jdt / eclipse-jdt/eclipse.jdt.core
Bug 543081 - Generic wildcard compiler bug
- Dominant language
- Java
- Stars
- 237
- Forks
- 195
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 47
Description
From https://bugs.eclipse.org/bugs/show_bug.cgi?id=543081
ecj accepts the following program:
```java
class A {}
class B {
// javac 8u112 emits a compile error
// Eclipse 4.9.0 compiler does NOT emit a compile error
B b;
// both do not emit a compile error, as expected
B b2;
}
```
javac reports:
```
B.java:6: error: type argument A is not within bounds of type-variable E
B b;
^
where E,T are type-variables:
E extends T declared in class B
T extends A declared in class B
1 error
```
ecj only starts to complain, when you try to assign a value that would violate the bounds:
```java
class A {}
class C extends A {}
class B {
// javac 8u112 emits a compile error
// Eclipse 4.9.0 compiler does NOT emit a compile error
B b = new B();
B bx = new B();
// both do not emit a compile error, as expected
B b2;
}
```
ecj reports:
```
1. ERROR in /tmp/B.java (at line 8)
B bx = new B();
^
Bound mismatch: The type A is not a valid substitute for the bounded parameter of the type B
----------
1 problem (1 error)
```
I'm not sure if this is enough, or if the declaration should already be flagged.
Contributor guide
Assessment
This issue has not been assessed yet.