4

I have come across a limitation with swift protocols:

protocol P {
}

protocol Q: P {
}

protocol R  {
    var p: P { get set }
}

struct S: R {
    var p: Q
}

The code appears to be correct, however it won't build because S doesn't conform to protocol R, which requires a property of type P.

Struct S has a property of type Q which, by definition, extends P.

Is this a bug or by design?

and

Can anyone propose a workaround?

cfergie
  • 621
  • 5
  • 4

0 Answers0