0

I am getting the error

Required type: Function<A, B>
Provided: Function<A,C<D>>
no instance(s) of type variable(s) exist so that Function<A, C<D>> conforms to Function<A, B>

Now B is an interface defined like

public interface B <U extends X, V extends Y> {}

C implements the interface B like

public abstract class C <T extends Y> implements B <X, T>

Now if I write something as

B data = getBean(SomeFactory.class);

where getBean(SomeFactory.class) gives an instance of C<D> then this statement is valid as C implements B. But if I write

Function<A,B> supplier = getBean(SomeSupplierFactory.class);

where getBean(SomeSupplierFactory.class) gives an instance of Function<A, C<D>> it throws the above error i.e.

Required type: Function<A, B>
Provided: Function<A,C<D>>
no instance(s) of type variable(s) exist so that Function<A, C<D>> conforms to Function<A, B>

even though C is an implementation of B

Please let me know what am I missing and how to make the above work. Thanks a lot.

Varun Sharma
  • 253
  • 1
  • 3
  • 16

0 Answers0