I do not know whether this category is right or not but I just had a minor and a major problem regarding the parameter packs.
The minor one is that the @autoclosure annotation is being ignored when being used with repeat keyword so that when:
func foo<T>(_ bar: repeat @autoclosure () -> each T)
is being called as
foo("some string", 1234, true)
Swift throws error
Cannot convert value of type 'String' to expected argument type '() -> _'
But when it is being called as
foo({"some string"}, {1234}, {true})
There is no error.
BUT the big problem I just uncovered about the parameter packs is about escaping/nonescaping properties of the closures.
func foo<T>(_ bar: repeat () -> each T) {
someEscapingClosureMethod {
SomeType.someOtherParameterPackMethod(repeat (each bar)())
}
}
The bar closure apparently should be annotated @escaping since it is captured by an escaping closure. But it isn’t and the code builds without any errors. But when the code runs it throws EXC_BAD_ACCESS.
func foo<T>(_ bar: repeat @escaping () -> each T) {
someEscapingClosureMethod {
SomeType.someOtherParameterPackMethod(repeat (each bar)())
}
}
builds and runs without any problems.