Why is this type not a valid substitute for the type parameter?

前端 未结 3 623
醉梦人生
醉梦人生 2020-12-28 23:14

I\'m experimenting with using generics to support a configurable structure of delegating objects (decorators, wrappers). I want to build a chain of delegators that implement

3条回答
  •  一个人的身影
    2020-12-28 23:29

    What should work instead is, if FooDelegator implements Delegator or Foo implements Delegator. Because this is what you are requiring for the DelegatorChain: T implements Delegator.

    Third alternative, which should work as well:

    DelegatorChain, F> chain; ...
    

提交回复
热议问题