Skip to content

Commit

Permalink
fix exhaustive switch error in Xcode 9
Browse files Browse the repository at this point in the history
  • Loading branch information
hirad committed Jul 14, 2017
1 parent 5b643a6 commit 19a5b0a
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions ReactiveObjCBridge/ObjectiveCBridging.swift
Original file line number Diff line number Diff line change
Expand Up @@ -486,15 +486,30 @@ public func bridgedTuple<First, Second, Third, Fourth, Fifth>(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
}
}

0 comments on commit 19a5b0a

Please sign in to comment.