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

Inference fails to generate self-bounded type variable

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 8u60, 9
    • 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>

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

              Created:
              Updated: