Say, I have a structure with a generic type parameter that requires a class type:
struct Foo<T: AnyObject> {}
As expected, I cannot use this structure with value types, but it works with class types:
// Error: 'Foo' requires that 'String' be a class type
let _ = Foo<String>()
// Working.
let _ = Foo<NSString>()
If I define a class-only protocol:
protocol Bar: AnyObject {}
I cannot, however, use the structure with this protocol:
// Error: 'Foo' requires that 'any Bar' be a class type
let _ = Foo<Bar>()
Why is that? And how would I work around this?