I want to understand the implications of any when using specialized generic protocols in Swift. Here is my code:
protocol ShapeA {
}
protocol ShapeB {
associatedtype AAA
}
protocol BaseC<T> {
associatedtype T
}
protocol ShapeC: BaseC<Int> {
}
protocol Maker {
func makeShapeA() -> ShapeA
func makeShapeB() -> any ShapeB
func makeShapeC() -> any ShapeC
}
- Why does
makeShapeCrequiresanybefore return type? From my perspectiveShapeCis a protocol that is fully specified, just likeShapeA. What exactly is the difference? - Why doesn't
makeShapeArequireany? It's existential type just according to the descriptions that I find online... - In case I leave the code as it is: is there an actual performance difference between
makeShapeAandmakeShapeCas they both return existential types as far as I can tell?