fork download
  1. import java.util.List;
  2. import java.util.function.Function;
  3.  
  4. class Test {
  5. interface Mapper<T, U extends MapperProvider<U>> extends Function<T, U> {}
  6.  
  7. interface MapperProvider<V> {
  8. Mapper<V, ?> provide();
  9. }
  10.  
  11. private <V extends MapperProvider<V>> void use(V c) {
  12. use2(c.provide().apply(c));
  13. }
  14.  
  15. private <W extends MapperProvider<W>> void use2(W c) {
  16. }
  17. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:12: error: method use2 in class Test cannot be applied to given types;
    	use2(c.provide().apply(c));
    	^
  required: W
  found: CAP#1
  reason: inference variable W has incompatible bounds
    equality constraints: CAP#1
    lower bounds: MapperProvider<CAP#1>
  where W is a type-variable:
    W extends MapperProvider<W> declared in method <W>use2(W)
  where CAP#1 is a fresh type-variable:
    CAP#1 extends MapperProvider<CAP#1> from capture of ?
1 error
stdout
Standard output is empty