Tinkering around with this question, I came up with this:
class AllTogether<T: FooProtocol> {
func createContainer<U: T>(data: U){
Container<T>(someDataConformingFooProtocol: data)
}
}
My understanding is that this should work if we make FooProtocol
a class protocol:
protocol FooProtocol: class { ... }
However, we still get errors:
Error: inheritance from non-protocol, non-class type 'T'
Error: argument type 'U' does not conform to expected type 'FooProtocol'
Both messages seem to be wrong. What am I missing?
Is the subtype relation not transitive in Swift?