eclipse-jdt / eclipse-jdt/eclipse.jdt.core
Diamond operator type inference fails under javac but not ECJ
- Dominant language
- Java
- Stars
- 237
- Forks
- 195
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 47
Description
The following minimal example produces a compiler error under javac but not ECJ:
```java
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
public class HelloWorld {
public static void main(String... args) {
Class[] classes = new Class[] { String.class, List.class };
List> asdf = new ArrayList<>(Arrays.asList(classes));
}
}
```
Here's the error that javac gives:
```
HelloWorld.java:9: error: incompatible types: cannot infer type arguments for ArrayList<>
List> asdf = new ArrayList<>(Arrays.asList(classes));
^
reason: cannot infer type-variable(s) E,T
(argument mismatch; List cannot be converted to Collection>)
where E,T are type-variables:
E extends Object declared in class ArrayList
T extends Object declared in method asList(T...)
```
Contributor guide
Assessment
This issue has not been assessed yet.