duemunk / Async

Syntactic sugar in Swift for asynchronous dispatches in Grand Central Dispatch
MIT License
4.59k stars 316 forks source link

Does not compile with Xcode 9 and Swift 4 #119

Closed ldiqual closed 7 years ago

ldiqual commented 7 years ago
let block = DispatchWorkItem(block: {
    reference.value = block()
})

// AsyncSwift/Sources/Async.swift:264:37: Missing argument for parameter #1 in call

Side note: I also tried to convert the Async project with Xcode 9 + Swift 4 but we get a bunch of errors due to Void => () conversion which requires declaring closure params explicitly, very annoying. Not sure if that's a swift 4 beta bug or something that needs to be worked on.

thierrybucco commented 7 years ago

+1

imxieyi commented 7 years ago

This works for me:

    private static func async<O>(after seconds: Double? = nil, block: @escaping () -> O, queue: GCD) -> AsyncBlock<Void, O> {
        let reference = Reference<O>()
        let block = DispatchWorkItem(block: {
            reference.value = block()
        })

        if let seconds = seconds {
            let time = DispatchTime.now() + seconds
            queue.queue.asyncAfter(deadline: time, execute: block)
        } else {
            queue.queue.async(execute: block)
        }

        // Wrap block in a struct since @convention(block) () -> Swift.Void can't be extended
        return AsyncBlock<Void, O>(block, output: reference)
    }
SF-Simon commented 7 years ago

I also need swift4, hoping to use it as soon as possible

hy9be commented 7 years ago

Same issue.

dearbar commented 7 years ago

From migration-guide-swift4 reference.value = block() change to reference.value = block(()) Maybe right!

edenman commented 7 years ago

122 looks like it would fix this, fwiw

mario-huang commented 7 years ago

+1

sushiwu commented 7 years ago

+1

dearbar commented 7 years ago

thanks

2017-09-27 10:36 GMT+08:00 returnight notifications@github.com:

+1

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/duemunk/Async/issues/119#issuecomment-332391760, or mute the thread https://github.com/notifications/unsubscribe-auth/AZh7y_yfriw17rH-TzOMTyQBUehAsLLLks5smbSigaJpZM4N5e9R .

rlam3 commented 7 years ago

@duemunk Any updates on this? Thanks!

duemunk commented 7 years ago

Fixed by #122