Consider the code below:
// OK
let res1: Result<Int, Error>? = nil
protocol MyError: Error { }
// Protocol 'MyError' as a type cannot conform to 'Error'
let res2: Result<Int, MyError>? = nil
Why cannot I use MyError protocol which extends Error here, is this behaviour is explained somewhere in the official docs?
And another example:
// Protocol 'MyProtocol' as a type cannot conform to the protocol itself
protocol MyProtocol { }
class MyClass<T: MyProtocol> { }
let c = MyClass<MyProtocol>()
// OK
class MyOtherClass<T: Error> { }
let c2 = MyOtherClass<Error>()
I might guess that Error is being bridged to NSError and used as a concrete class, not a Swift protocol; but when we're using MyError that logic does not kick in. Any references?