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

Inference fails to generate self-bounded type variable

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 8u60, 9
    • Fix Version/s: tbd_minor
    • Component/s: tools
    • Labels:

      Description

      This fails with a compiler error:

          <S> Iterable<S> id(Iterable<S> arg) { return arg; }
          <T extends Comparable<T>> Iterable<T> empty() { return null; }
          void test() { id(empty()); }

      So does this:

          <S extends Comparable<S>> Iterable<S> id(Iterable<S> arg) { return arg; }
          <T> Iterable<T> empty() { return null; }
          void test() { id(empty()); }

      This succeeds:

          <T extends Comparable<T>> Iterable<T> empty() { return null; }
          void test() { empty(); }

      All ought to succeed (per JLS 18.4), generating a type variable of the form:
      Z extends Comparable<Z>

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            dlsmith Dan Smith
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: