Promisekit: "Ambiguous use of fulfill" when upgrading to 6.7.1

Created on 23 Jan 2019  Â·  10Comments  Â·  Source: mxcl/PromiseKit

  • Please specify the PromiseKit major version you are using:

problem manifests with PromiseKit 6.7.1, installed via cocoapods. We recently upgraded from 6.5.3 which did not have this issue, but I believe the problem was introduced with 33e7eba in 6.6.0

description

We have a lot of methods which wrap legacy success/failure style methods with a promise like this:

 private func registerForTextSecure(verificationCode: String,
                                       pin: String?) -> Promise<Void> {
        return Promise { resolver in
            tsAccountManager.verifyAccount(withCode: verificationCode,
                                           pin: pin,
                                           success: resolver.fulfill,
                                           failure: resolver.reject)
        }
    }

Upon upgrading from 6.5.3 to 6.7.1 we get the compiler error: Ambiguous use of fulfill

The following patch resolves the issue:

$ git diff diff --git a/PromiseKit/Sources/Resolver.swift b/PromiseKit/Sources/Resolver.swift index 297de03..be89de0 100644 --- a/PromiseKit/Sources/Resolver.swift +++ b/PromiseKit/Sources/Resolver.swift @@ -62,14 +62,9 @@ extension Resolver where T == Void { if let error = error { reject(error) } else { - fulfill() + fulfill(()) } } - - /// Fulfills the promise - public func fulfill() { - self.fulfill(()) - } } #endif

So it seems like this was introduced with 33e7eba in 6.6.0. (A change which I'm sympathetic to by the way!)

Is there a different way we should be wrapping these handlers?

Most helpful comment

Thanks, this is a serious API breakage and I thank you for your patience. I am reverting the change even though it has been months and no doubt some people have worked-around this issue. This is unfortunate, but it’s the right thing to do.

We will reintegrate this for PMK7 and the ambiguity will then have to stand, the workaround will be to pass a closure that calls fulfill().

All 10 comments

Thanks, this is a serious API breakage and I thank you for your patience. I am reverting the change even though it has been months and no doubt some people have worked-around this issue. This is unfortunate, but it’s the right thing to do.

We will reintegrate this for PMK7 and the ambiguity will then have to stand, the workaround will be to pass a closure that calls fulfill().

Thanks for the prompt response!

Happy to help! Though it’s only possible to be this prompt because I'm full-time.

Donate if you can! https://patreon.com/mxcl

Happy to help! Though it’s only possible to be this prompt because I'm full-time.

Donate if you can! https://patreon.com/mxcl

I'm already on it. =)

Thanks for your work!

Oh indeed! Sorry, I need to be better at recognizing that. Thanks so much for your contribution, it’s much appreciated. You qualify for me tweeting out thanks actually, you want me to do that for Signal app?

Sure!

On Jan 23, 2019, at 12:18, Max Howell notifications@github.com wrote:

Oh indeed! Sorry, I need to be better at recognizing that. Thanks so much for your contribution, it’s much appreciated. You qualify for me tweeting out thanks actually, you want me to do that for Signal app?

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.

Great! Will schedule for tomorrow.

Battling CI with the PR, but should be merged soon and then will release 6.8.0.

6.8.0 is tagged, it is processing through CI and will deploy once done.

Not good news: this is no longer possible in Swift 5. Our ambiguity test fails.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

daanporon picture daanporon  Â·  6Comments

kikeenrique picture kikeenrique  Â·  6Comments

dboydor picture dboydor  Â·  4Comments

zvonicek picture zvonicek  Â·  3Comments

jshier picture jshier  Â·  4Comments