eclipse-jdt / eclipse-jdt/eclipse.jdt.core
Ecj uses same capture for some wildcards for method references whereas javac uses different captures
- Dominant language
- Java
- Stars
- 237
- Forks
- 195
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 49
Description
Found while working on #2321
With:
```java
public void test() {
A, B> a = this::error;
}
public void error(B a, B b) {}
interface A {
void run(T t, U u);
}
class B {}
```
Javac will error with
```
.\TestRecord.java:12: error: incompatible types: invalid method reference
A, B> a = this::error;
^
method error in class TestRecord cannot be applied to given types
required: TestRecord.B,TestRecord.B
found: TestRecord.B,TestRecord.B
reason: inference variable T has incompatible equality constraints CAP#1,CAP#2
where T is a type-variable:
T extends Object declared in method error(TestRecord.B,TestRecord.B)
where CAP#1,CAP#2 are fresh type-variables:
CAP#1 extends Object from capture of ?
CAP#2 extends Object from capture of ?
```
whereas ecj successfully compiles.
ecj reuses the same `ParameterizedTypeBinding` for both references to `B`.
Contributor guide
Assessment
This issue has not been assessed yet.