I am dealing with the following puzzle.
class Product {}
static class Fruit extends Product implements Comparable<Fruit> {}
class Apple extends Fruit {}
Function<? super Fruit, ? extends Comparable> fx = Fruit::getCost;
Fruit fruit = new Fruit(1);
Product product = new Product();
fx.apply(product); <-- compile error?
What might be the reason fx not to accept Product object as argument? Product is parent of Fruit i.e. satisfies "? super Fruit" definition.
Function<? extends Fruit, ? extends Comparable> fx = Fruit::getCost;
Fruit fruit = new Fruit(1);
Apple apple = new Apple(2);
fx.apply(apple); <-- compile error?
Why apple would not be accepted as argument when its type is subtype of Fruit? Apple should satisfy "? extends Fruit".