Open zetasq opened 5 months ago
Just bumped into the same restriction as well. It seems odd that existential types aren't more flexible w.r.t. AnyObject
.
If it helps, the limitation can be worked around in some cases by marking the protocol @objc
, as pointed out in this thread on Apple Developer Forums as well as manifested in Swift unit tests: test/Generics/existential_restrictions.swift
.
Description
After declaring a generic parameter
T
which conforms toAnyObject
, I can't fulfill it with an existential typeany P
whereP
conforms toAnyObject
.Reproduction
Expected behavior
The code above should compile successfully.
Environment
Swift 5.10
Additional information
No response