I'm trying to understand why the compiler allows an input parameter of type some Sequence<some Sequence<Element>>
in the initialiser/function but doesn't allow it as a return type of computed property/function.
This is an example I've stumbled upon:
struct Matrix<Element> {
init(rows: some Sequence<some Sequence<Element>>) {
// OK
}
var rows: some Sequence<some Sequence<Element>> {
// Errors:
// 'some' types are only permitted in properties, subscripts, and functions
// Use of protocol 'Sequence<Element>' as a type must be written 'any Sequence<Element>'
}
}
To my understanding, both cases should be valid. However, they are treated differently as of Xcode 16.1, Swift 6.0.2.
Does anyone know why this distinction exists and what's its purpose? Any insights or references would be greatly appreciated!