0

I have an Interface IParent, an abstract class implementing it AbstractChild and a class extending the abstract class ConcreteChild. One other class Foo requires an instance of a Supplier<IParent>.

My problem is that I have an instance of a Supplier<ConceretChild> and I cannot cast it to the Supplier<IParent> I need or just pass it straight up.

The only thing I have tried is of course:

((Supplier<IParent>)childSupplier)

Compiler says cannot cast from Supplier<Child> to Supplier<Parent>.

LeffeBrune
  • 3,361
  • 1
  • 22
  • 35
Kostas Thanasis
  • 338
  • 3
  • 11

0 Answers0