|
Duplicate :
|
|
|
Relates :
|
|
|
Relates :
|
The following fails to compile:
---
public class FirstNonNull {
public static class C<T> {}
public static <T> T firstNonNull(T first, T second) {
return first != null ? first : second;
}
public static C<String> doesNotCompile = firstNonNull(new C<String>(), new C<>());
}
---
Error:
public static C<String> doesNotCompile = firstNonNull(new C<String>(), new C<>());
^
inferred: C<? extends Object>
upper bound(s): C<String>,Object
---
This is a regression -- it compiles correctly with the initial release of JDK 8.
Reported on Stack Overflow: http://stackoverflow.com/questions/25490581
|