google / promises

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

Swift 4.1 error: Ambiguous use of operator '==' #27

Closed richardtop closed 6 years ago

richardtop commented 6 years ago

Hi, I got an error when working with Swift 4.1 and Xcode 9.3 beta 3 (9Q117m), when installing the framework using CocoaPods v1.4.0: image

Not critical now, stable Xcode 9.2 and Swift 4 work correctly.

Removing this piece of code makes it compile:

    static func == (lhs: When<Value?>, rhs: When<Value?>) -> Bool {
      switch (lhs, rhs) {
      case (.value(let lhs), .value(let rhs)):
        switch (lhs, rhs) {
        case (nil, nil):
          return true
        case (nil, _?), (_?, nil):
          return false
        case let (lhs?, rhs?):
          return lhs == rhs
        }
      case (.error(let lhs), .error(let rhs)):
        return (lhs as NSError).isEqual(rhs as NSError)
      case (.value, .error), (.error, .value):
        return false
      }
    }

Introduction of the conditional conformance in Swift 4.1 might be the root cause.

shoumikhin commented 6 years ago

Thanks, Richard! The issue should be resolved in 1.0.6.

richardtop commented 6 years ago

Thanks for the quick release! However, I think, it has to be revisited when Swift 4.1 comes out of the beta.