Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not compile with Xcode 9 and Swift 4 #119

Closed
ldiqual opened this issue Jun 14, 2017 · 11 comments
Closed

Does not compile with Xcode 9 and Swift 4 #119

ldiqual opened this issue Jun 14, 2017 · 11 comments

Comments

@ldiqual
Copy link
Contributor

ldiqual commented Jun 14, 2017

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
Copy link

+1

@imxieyi
Copy link

imxieyi commented Aug 4, 2017

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
Copy link

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

@hy9be
Copy link

hy9be commented Aug 30, 2017

Same issue.

@dearbar
Copy link

dearbar commented Sep 20, 2017

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

@edenman
Copy link

edenman commented Sep 22, 2017

#122 looks like it would fix this, fwiw

@mario-huang
Copy link

+1

1 similar comment
@sushiwu
Copy link

sushiwu commented Sep 27, 2017

+1

@dearbar
Copy link

dearbar commented Sep 27, 2017 via email

@rlam3
Copy link

rlam3 commented Sep 29, 2017

@duemunk Any updates on this? Thanks!

@duemunk
Copy link
Owner

duemunk commented Oct 23, 2017

Fixed by #122

@duemunk duemunk closed this as completed Oct 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests