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

regression: return-type inference rejects valid code

XMLWordPrintable

    • b64
    • unknown
    • generic
    • Verified

      import java.util.Comparator;
      import java.util.List;

      class Test {
         <T extends Comparable<? super T>> Comparator<List<T>> comparator() { return null; }
         static <T extends Comparable<? super T>> void f() {
            Comparator<List<T>> comparator = comparator(); // [*]
         }
      }


      this program is rejected with the following error message:

       type parameters of <T>java.util.Comparator<java.util.List<T>> cannot be determined;
          no unique maximal instance exists for type variable T with upper bounds java.lang.Comparable<? super T>



      See also http://www.netbeans.org/issues/show_bug.cgi?id=163967
      http://www.netbeans.org/issues/show_bug.cgi?id=163969

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: