Hey @jonprescott!
Thanks for the response, I appreciate you jumping in to help me solve this problem!
For your first point, I'm not sure that is true. The where Self: UIViewController clause restricts the protocol from being used anywhere except on UIViewControllers.
Take the following example...
protocol CardController where Self: UIViewController {}
class MyVC: UIViewController, CardController {}
func test() {
let presentingVC: CardController = MyVC()
let modal = UIViewController()
presentingVC.present(modal, animated: true, completion: nil)
}
Here we have assigned a MyVC to to presentingVC which is a CardController and we still have access to present a function on UIViewController. So even though preventingVC is a CardController, it is still a UIViewController too, per the Self restriction in the protocol.
If the Self restriction was on an extension, I think your point would be valid, but because the Self restriction is on the protocol itself, all CardControllers must be UIViewControllers.
This restriction can be further shown with this example.
protocol CardController where Self: UIViewController {}
class MyObj: CardController {}
This will return an error saying that 'CardController' requires that 'MyObj' inherit from 'UIViewController'
The ability to restrict protocols to specific objects/classes exists, so we know that ALL CardControllers are UIViewControllers so which can't swift synthesize Hashable
Again, I have a better solution in my current use case, however I am trying to understand why this doesn't work from a conceptual point of view. Is this a Swift implementation detail that has not been implemented yet, or am I missing something more?