Hope I'm not wrong here. And I would be interested by the correct answer to this post.
You are applying any to a protocol. I read that would only be availabale with Swift 6 (Xcode 14 is Swift 5.7 : https://swiftversion.net/).
However, example given in SE-0352 (implemented in Swift 5.7) tells it is possible
https://github.com/apple/swift-evolution/blob/main/proposals/0352-implicit-open-existentials.md
And you're right, it is very similar to SE-0352, so it should work.
Unless it is not yet in 14 beta ?
If that may help, I noted that this works:
| func feedAll(_ animals: [any Animal]) { |
| for animal in animals { |
| print("all ->", animal) |
| if animal is Horse { |
| feed(Horse()) |
| } |
| if animal is Dog { |
| feed(Dog()) |
| } |
| } |
| } |