Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7086586

Inference producing null type argument

XMLWordPrintable

    • b08
    • generic
    • generic
    • Verified

        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>>
        }

              mcimadamore Maurizio Cimadamore
              dlsmith Dan Smith
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: