-
Bug
-
Resolution: Fixed
-
P4
-
7
-
b08
-
generic
-
generic
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2213800 | 7u4 | Dmeetry Degrave | P3 | Closed | Fixed | b01 |
When the inference algorithm determines that an inference variable is a subtype of a capture variable without a lower bound, it may choose "null" as the inference result. This is inconsistent with specified behavior.
<T> Iterable<T> empty(Iterable<? super T> dummy) { return null; }
{
String s = empty((Iterable<?>) null).iterator().next(); // no error reported
Number n = empty((Iterable<?>) null).iterator().next(); // no error reported
Exception e = empty((Iterable<?>) null).iterator().next(); // no error reported
empty((Iterable<?>) null).foo(); // error: can't find in Iterable<<null>>
}
<T> Iterable<T> empty(Iterable<? super T> dummy) { return null; }
{
String s = empty((Iterable<?>) null).iterator().next(); // no error reported
Number n = empty((Iterable<?>) null).iterator().next(); // no error reported
Exception e = empty((Iterable<?>) null).iterator().next(); // no error reported
empty((Iterable<?>) null).foo(); // error: can't find in Iterable<<null>>
}
- backported by
-
JDK-2213800 Inference producing null type argument
-
- Closed
-
- relates to
-
JDK-6650759 Inference of formal type parameter (unused in formal parameters) is not performed
-
- Closed
-
-
JDK-8033718 Inference ignores capture variable as upper bound
-
- Closed
-