I'm trying to write a result builder using the new buildPartialBlock
API. What I try to do is in fact pretty straightforward. Given:
public protocol Command: Hashable, Sendable {}
struct CommandPair<C0, C1>: Command where C0: Command, C1: Command {
let first: C0
let second: C1
}
@resultBuilder
public enum CommandBuilder {
static func buildPartialBlock(first command: some Command) -> some Command {
command
}
static func buildPartialBlock(accumulated: some Command, next: some Command) -> some Command {
CommandPair(first: accumulated, second: next)
}
}
I would expect this to work:
let block = CommandBlock {
AuthCommand.update
CommandBlock {
AuthCommand.logout
AuthCommand.update
}
}
Where both AuthCommand
and CommandBlock
are conforming to Command
. However, I get this weird error message: Result builder 'CommandBuilder' does not implement any 'buildBlock' or a combination of 'buildPartialBlock(first:)' and 'buildPartialBlock(accumulated:next:)' with sufficient availability for this call site
. Which doesn't seem to be the case since the methods are there.
What do I do wrong? How should I debug this?