Is this a known limitation? I'm using Swift 5.1 and when I'm trying to do this:
let closure = { (size: CGSize) -> some View in
...
}
I'm getting a couple of errors, the leading one being: Consecutive statements on a line must be separated by ';'.
However, if using a func, same declaration works perfectly. Is this a known issue or limitation?
Adding a type annotation to the closure variable gives a more informative error message:
protocol P { }
extension Int : P { }
let closure: () -> some P = { return 13 }
// 'some' types are only implemented for the declared type
// of properties and subscripts and the return type of functions
Closures cannot currently have opaque return types, though they could in the future.
Opaque types become the underlying type at runtime. There shouldn't be any implementation limitation preventing closures from having opaque return types.