I know this is swiftui, and Xcode, but I believe the question could be reduced to a non-swiftui generics/result builders example.
I have a project which contained a function which worked prior to Xcode 16.3. This was created in Dec/24. I was a bit surprised at the time that it worked, but shrugged and moved on; until 16.3 hit. I developed a manual unrolled work around which is really, really ugly and would require extensive unit tests for complete coverage. So I was wondering is there another solution similar to the more elegant approach. Briefly reviewing typed parameter packs, I came up empty. Is there such an approach, or should the original approach work?
Here is an isolated version of the problematic function:
import SwiftUI
struct ContainingProblemFunction<Comp:ViewModifier>: ViewModifier {
public
func body(content: Content) -> some View {
EmptyView()
}
// WARNING: Rather doubtful this will work.
@ViewBuilder
private
func apply(modifiers: [Comp], toContent content: some View) ->
some View {
if !modifiers.isEmpty,
let next = modifiers.first {
let newContent =
ModifiedContent(content: content, modifier: next)
if modifiers.count > 1 {
let rest = [Comp](modifiers.dropFirst())
apply(modifiers: rest, toContent: newContent)
}
else {
newContent
}
}
else {
content
}
}
}