In this code:
protocol TestProtocol {
var someVar: String { get }
}
protocol WithTestProtocol {
var someVarWithTestProtocol: TestProtocol { get }
}
struct TestProtocolStruct: TestProtocol {
var someVar: String {
return ""
}
}
struct WithTestProtocolStruct: WithTestProtocol {
var someVarWithTestProtocol: TestProtocolStruct {
return TestProtocolStruct()
}
}
I get the error message:
Type 'WithTestProtocolStruct' does not conform to protocol 'WithTestProtocol'
Why is it not possible to conform to a protocol with a concrete implementation? Are there good workarounds?
I know, that this code works:
struct WithTestProtocolStruct: WithTestProtocol {
var someVarWithTestProtocol: TestProtocol {
return TestProtocolStruct()
}
}
.. but I need to use a concrete implementation there because I want to use other stuff of the concrete implementation. I thought, it is a very common case and I`m wondering, why the compiler does not allow this.