From 19a5b0a34d1f51520e835f7dac6fc30a92f4c3da Mon Sep 17 00:00:00 2001 From: Hirad Motamed Date: Fri, 14 Jul 2017 15:37:34 -0700 Subject: [PATCH] fix exhaustive switch error in Xcode 9 --- ReactiveObjCBridge/ObjectiveCBridging.swift | 35 +++++++++++++++------ 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/ReactiveObjCBridge/ObjectiveCBridging.swift b/ReactiveObjCBridge/ObjectiveCBridging.swift index fb2f9b55c..b468dc1b6 100644 --- a/ReactiveObjCBridge/ObjectiveCBridging.swift +++ b/ReactiveObjCBridge/ObjectiveCBridging.swift @@ -486,15 +486,30 @@ public func bridgedTuple(from tuple: RACFiv extension DispatchTimeInterval { fileprivate var timeInterval: TimeInterval { - switch self { - case let .seconds(s): - return TimeInterval(s) - case let .milliseconds(ms): - return TimeInterval(TimeInterval(ms) / 1000.0) - case let .microseconds(us): - return TimeInterval(UInt64(us) * NSEC_PER_USEC) / TimeInterval(NSEC_PER_SEC) - case let .nanoseconds(ns): - return TimeInterval(ns) / TimeInterval(NSEC_PER_SEC) - } + #if swift(>=3.2) + switch self { + case let .seconds(s): + return TimeInterval(s) + case let .milliseconds(ms): + return TimeInterval(TimeInterval(ms) / 1000.0) + case let .microseconds(us): + return TimeInterval(Int64(us) * Int64(NSEC_PER_USEC)) / TimeInterval(NSEC_PER_SEC) + case let .nanoseconds(ns): + return TimeInterval(ns) / TimeInterval(NSEC_PER_SEC) + case .never: + return .infinity + } + #else + switch self { + case let .seconds(s): + return TimeInterval(s) + case let .milliseconds(ms): + return TimeInterval(TimeInterval(ms) / 1000.0) + case let .microseconds(us): + return TimeInterval(Int64(us) * Int64(NSEC_PER_USEC)) / TimeInterval(NSEC_PER_SEC) + case let .nanoseconds(ns): + return TimeInterval(ns) / TimeInterval(NSEC_PER_SEC) + } + #endif } }