I want to implement next code structure:
// Base hierarchy definition
protocol A {}
protocol C {
var a: A { get set }
}
// Specific definition
protocol B: A {}
struct TestClass: C {
var a: B
}
- Protocol
Crequires variable of typeA. - Protocol
Bwas inherited fromA. - Class
TestClassimplementsCprotocol by defining variable of typeB(what should be ok in order of2)
But Swift compiler complains that TestClass doesn't conform to protocol C because Candidate has non-matching type 'B'.
Why Swift compiler takes type B as non-matching to type A?