Inference fails to generate self-bounded type variable

XMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: P4
    • tbd
    • Affects Version/s: 8u60, 9
    • Component/s: tools

      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>

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

              Created:
              Updated: