Parameter pack provided by closure argument

I have an existing utility for capturing an instance method of an Actor without strongly currying self

extension Actor {
    /// Make a closure from an instance method on an Actor without introducing a retain cycle.
    ///
    /// This unchecked variant is available for when @Sendable conformance isn't available.
    /// The checked variant is strongly preferred.
    ///
    /// - Parameters:
    ///   - uncheckedAction: usually an instance method from an Actor taken as a static function that takes the Actor as an argument and returns the instance method.
    /// - Returns: closure matching instance method signature with self curried weakly
    @inlinable
    func target<Input>(
        uncheckedAction: @escaping (isolated Self) -> (Input) async -> Void
    ) -> (Input) async -> Void {
        return { [weak self] in
            guard let self = self else { return }
            return await uncheckedAction(self)($0)
        }
    }
}

I currently have several overloads to handle different numbers of arguments, but I'd love to move over to Parameter Packs so I can have just one.

    /// Make a closure from an instance method on an Actor without introducing a retain cycle.
    ///
    /// This unchecked variant is available for when @Sendable conformance isn't available.
    /// The checked variant is strongly preferred.
    ///
    /// - Parameters:
    ///   - uncheckedAction: usually an instance method from an Actor taken as a static function that takes the Actor as an argument and returns the instance method.
    /// - Returns: closure matching instance method signature with self curried weakly
    @inlinable
    func target<FirstInput, each Input>(
        uncheckedAction: @escaping (isolated Self) -> (FirstInput, repeat (each Input)) async -> Void
    ) -> (FirstInput, repeat (each Input)) async -> Void {
        return { [weak self] in
            guard let self = self else { return }
            return await uncheckedAction(self)($0, repeat (each $1))
        }
    }

but so far I'm unable to unpack the second argument to my closure

Showing All Issues
TargetAction/Actors.swift:54:16: Pack expansion requires that '_' and 'each Input' have the same shape

TargetAction/Sources/TargetAction/Actors.swift:54:16: Cannot convert return expression of type '(FirstInput, _) async -> ()' to return type '(FirstInput, repeat (each Input)) async -> Void'
1 Like