| Summary: | [1.8][compiler][null] "Cannot infer type argument" but only with Null Analysis enabled | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Clovis Seragiotto <clovis.seragiotto> |
| Component: | Core | Assignee: | Stephan Herrmann <stephan.herrmann> |
| Status: | RESOLVED DUPLICATE | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | srikanth_sankaran |
| Version: | 4.4 | ||
| Target Milestone: | 4.5 M1 | ||
| Hardware: | PC | ||
| OS: | Windows NT | ||
| Whiteboard: | |||
Note: no error is issued if I use a factory method intead of new Foo<>(element)
static <T> Foo<T> x(T element) {
return newFoo(element);
}
static <T> Foo<T> newFoo(T element) {
throw new UnsupportedOperationException();
}
Build id: 20140925-1800 JDK Compliance: JavaSE-1.8 I can reproduce with 4.4.x but not after bug 440759 was fixed. This is not a perfect match, but that's all I can see now. Please re-open if the problem can be observed with recent builds (e.g., 4.5M1 or later). *** This bug has been marked as a duplicate of bug 440759 *** |
The following program can be compiled with Null Analysis disabled. With Null Analysis enabled, one gets the error "Cannot infer type arguments for Foo<>" at line 6. (Perhaps one or more @Nullable/@NonNull are missing, but the error message gives no hint where). package foobar; @org.eclipse.jdt.annotation.NonNullByDefault class Bar<E> { static <T> Foo<T> x(T element) { return new Foo<>(element); } public static class Foo<T> { T t; Foo(T t) { this.t = t; } } }