$ 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
$
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
$
- duplicates
-
JDK-6468354 Type inference fails on method w/type parm "T extends Comparable<? super T>"
- Closed