0
public class X<T> implements Future<T> {

    public void addListener(Consumer<? extends Future<? super T>> listener) {
      listener.accept(this);
    }

  }

It complains that the capture type cannot be applied

azro
  • 53,056
  • 7
  • 34
  • 70
Nat
  • 3,587
  • 20
  • 22
  • 1
    Because you allow a `Consumer` working on a more "precise" type than `Future` which doesn't necessarily has to be `X`. – Izruo Oct 19 '17 at 22:34
  • Thanks @lzruo. I was looking for a way to achieve this properly. Is there a way to do that? Currently, I have to use "uncheck" to perform a call and bypass generic type check instead. – Nat Oct 19 '17 at 22:54
  • 1
    @Nat well, `Consumer>`, `Consumer>` or `Consumer super Future super T>>` would work. Don't bypass type checking, it's rightly telling you there's a problem. – Andy Turner Oct 19 '17 at 22:58

0 Answers0