I'm trying to specify a class only protocol as generic using Swift 4, but I cannot get it to work. Consider the following code:
protocol SomeProtocol: class {
}
class Bar {
var foo = Foo<SomeProtocol>()
}
class Foo<Element: AnyObject> {
}
This results in the compiler error: 'SomeProtocol' is not convertible to 'AnyObject'. This should be the case however, since SomeProtocol is a class-only protocol.
Adding AnyObject to the protocol specification also doesn't make a difference.