protocol-inheritance

How to make protocol associated type require protocol inheritance and not protocol adoption

戏子无情 提交于 2019-11-30 18:05:43
问题 In my swift project I have a case where I use protocol inheritance as follow protocol A : class{ } protocol B : A{ } What Im trying to achieve next is declaring another protocol with associated type, a type which must inherit from protocol A . If I try to declare it as : protocol AnotherProtocol{ associatedtype Type : A weak var type : Type?{get set} } it compiles without errors but when trying to adopt AnotherProtocol in the following scenario: class SomeClass : AnotherProtocol{ typealias