google / promises

Promises is a modern framework that provides a synchronization construct for Swift and Objective-C.
Apache License 2.0
3.8k stars 293 forks source link

Promise+Retry.swift fails to build for swift version <= 4 #55

Closed adlerj closed 6 years ago

adlerj commented 6 years ago

When we are on swift version < 4.1 the predicateBlock has type var predicateBlock: ((_ count: Int, _ error: Error) -> ObjCBool)?

This gives an error when used below in the onQueue call because the condition type is defined as: typedef BOOL (^FBLPromiseRetryPredicateBlock)(NSInteger, NSError *)

Cannot convert value of type '((Int, Error) -> ObjCBool)?' to expected argument type '((Int, Error) -> Bool)?'
adlerj commented 6 years ago

I'm not sure that the swift version check is even necessary...

"C typedefs of block types are imported as typealiass for Swift closures.

The primary result of this is that typedefs for blocks with a parameter of type BOOL are imported as closures with a parameter of type Bool (rather than ObjCBool as in the previous release). This matches the behavior of block parameters to imported Objective-C methods. (22013912)"

https://github.com/apple/swift/blob/master/CHANGELOG.md

ghost commented 6 years ago

Appears that the issue has to do with the Xcode version rather than a specific Swift version. So checking if Swift version is >=4.1 will not suffice.

Based on the check used here: https://github.com/realm/SwiftLint/pull/2038/commits/133cef8df1af0e9c4a8efc98a2ce63f39c530f72

We will need to do the following: (!swift(>=4.1) || (!swift(>=4.0) && swift(>=3.3)))

jonathanekim commented 6 years ago

I believe #59 fixes this issue. Please reopen if it does not!