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

Problem with underconstrained type variable and super bounded wildcards

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P5
    • Resolution: Duplicate
    • Affects Version/s: 6
    • Fix Version/s: None
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      $ cat -n A.java
           1 import java.util.*;
           2 class Comparators {
           3 public static <C extends Comparable<? super C>> Comparator<C> naturalOrder() {
           4 return null;
           5 }
           6 public static Comparator<Integer> c() {
           7 return naturalOrder();
           8 }
           9 }
      $ /usr/local/jdk6/bin/javac A.java
      A.java:7: incompatible types; no instance(s) of type variable(s) C exist so that java.util.Comparator<C> conforms to java.util.Comparator<java.lang.Integer>
      found : <C>java.util.Comparator <C>
      required: java.util.Comparator<java.lang.Integer>
          return naturalOrder();
                             ^
      1 error
      $

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                ahe Peter Ahe
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: