I am trying to define a P2 protocol so that it returns a generic class with a restriction on another P1 protocol, for example:
protocol P1 {} class C<T : P1> {} public protocol P2 { typealias T class func c() -> C<T> }
But this leads to the following compiler error:
error: type 'T' does not conform to protocol 'P1' class func c() -> C<T>
It seems that there is no combination that allows this, for example. following obvious syntax:
protocol P1 {} class C<T : P1> {} public protocol P2 { typealias T class func c() -> C<T : P1> }
Errors with:
error: expected '>' to complete generic argument list class func c() -> C<T : P1> ^ note: to match this opening '<' class func c() -> C<T : P1>
Can this be done in Swift?
mythz source share