Skip to content

[gardening][Overlay] Prefer macOS over OSX for #available #15230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stdlib/public/SDK/Accelerate/BNNS.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ extension BNNSActivation {
public init(function: BNNSActivationFunction,
alpha: Float = .nan,
beta: Float = .nan) {
if #available(OSX 10.13, iOS 11.0, tvOS 11.0, watchOS 4.0, *) {
if #available(macOS 10.13, iOS 11.0, tvOS 11.0, watchOS 4.0, *) {
_precondition(function != .integerLinearSaturate,
"This initializer cannot be used with the integerLinearSaturate activation function; use BNNSActivation.integerLinearSaturate(scale:Int32, offset:Int32, shift:Int32) instead.")
_precondition(function != .integerLinearSaturatePerChannel,
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/SDK/Dispatch/Dispatch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public enum DispatchTimeoutResult {

public extension DispatchGroup {
public func notify(qos: DispatchQoS = .unspecified, flags: DispatchWorkItemFlags = [], queue: DispatchQueue, execute work: @escaping @convention(block) () -> Void) {
if #available(OSX 10.10, iOS 8.0, *), qos != .unspecified || !flags.isEmpty {
if #available(macOS 10.10, iOS 8.0, *), qos != .unspecified || !flags.isEmpty {
let item = DispatchWorkItem(qos: qos, flags: flags, block: work)
_swift_dispatch_group_notify(self, queue, item._block)
} else {
Expand Down
16 changes: 8 additions & 8 deletions stdlib/public/SDK/Dispatch/Queue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public extension DispatchQueue {
if self.contains(.concurrent) {
attr = _swift_dispatch_queue_concurrent()
}
if #available(OSX 10.12, iOS 10.0, tvOS 10.0, watchOS 3.0, *) {
if #available(macOS 10.12, iOS 10.0, tvOS 10.0, watchOS 3.0, *) {
if self.contains(.initiallyInactive) {
attr = __dispatch_queue_attr_make_initially_inactive(attr)
}
Expand Down Expand Up @@ -93,7 +93,7 @@ public extension DispatchQueue {
case never

internal func _attr(attr: __OS_dispatch_queue_attr?) -> __OS_dispatch_queue_attr? {
if #available(OSX 10.12, iOS 10.0, tvOS 10.0, watchOS 3.0, *) {
if #available(macOS 10.12, iOS 10.0, tvOS 10.0, watchOS 3.0, *) {
switch self {
case .inherit:
// DISPATCH_AUTORELEASE_FREQUENCY_INHERIT
Expand Down Expand Up @@ -154,11 +154,11 @@ public extension DispatchQueue {
if autoreleaseFrequency != .inherit {
attr = autoreleaseFrequency._attr(attr: attr)
}
if #available(OSX 10.10, iOS 8.0, *), qos != .unspecified {
if #available(macOS 10.10, iOS 8.0, *), qos != .unspecified {
attr = __dispatch_queue_attr_make_with_qos_class(attr, qos.qosClass.rawValue, Int32(qos.relativePriority))
}

if #available(OSX 10.12, iOS 10.0, tvOS 10.0, watchOS 3.0, *) {
if #available(macOS 10.12, iOS 10.0, tvOS 10.0, watchOS 3.0, *) {
self.init(__label: label, attr: attr, queue: target)
} else {
self.init(__label: label, attr: attr)
Expand Down Expand Up @@ -209,7 +209,7 @@ public extension DispatchQueue {
}

var block: @convention(block) () -> Void = work
if #available(OSX 10.10, iOS 8.0, *), (qos != .unspecified || !flags.isEmpty) {
if #available(macOS 10.10, iOS 8.0, *), (qos != .unspecified || !flags.isEmpty) {
let workItem = DispatchWorkItem(qos: qos, flags: flags, block: work)
block = workItem._block
}
Expand Down Expand Up @@ -279,7 +279,7 @@ public extension DispatchQueue {
public func sync<T>(flags: DispatchWorkItemFlags, execute work: () throws -> T) rethrows -> T {
if flags == .barrier {
return try self._syncHelper(fn: _syncBarrier, execute: work, rescue: { throw $0 })
} else if #available(OSX 10.10, iOS 8.0, *), !flags.isEmpty {
} else if #available(macOS 10.10, iOS 8.0, *), !flags.isEmpty {
return try self._syncHelper(fn: sync, flags: flags, execute: work, rescue: { throw $0 })
} else {
return try self._syncHelper(fn: sync, execute: work, rescue: { throw $0 })
Expand All @@ -292,7 +292,7 @@ public extension DispatchQueue {
flags: DispatchWorkItemFlags = [],
execute work: @escaping @convention(block) () -> Void)
{
if #available(OSX 10.10, iOS 8.0, *), qos != .unspecified || !flags.isEmpty {
if #available(macOS 10.10, iOS 8.0, *), qos != .unspecified || !flags.isEmpty {
let item = DispatchWorkItem(qos: qos, flags: flags, block: work)
_swift_dispatch_after(deadline.rawValue, self, item._block)
} else {
Expand All @@ -306,7 +306,7 @@ public extension DispatchQueue {
flags: DispatchWorkItemFlags = [],
execute work: @escaping @convention(block) () -> Void)
{
if #available(OSX 10.10, iOS 8.0, *), qos != .unspecified || !flags.isEmpty {
if #available(macOS 10.10, iOS 8.0, *), qos != .unspecified || !flags.isEmpty {
let item = DispatchWorkItem(qos: qos, flags: flags, block: work)
_swift_dispatch_after(wallDeadline.rawValue, self, item._block)
} else {
Expand Down
6 changes: 3 additions & 3 deletions stdlib/public/SDK/Dispatch/Source.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public extension DispatchSourceProtocol {
typealias DispatchSourceHandler = @convention(block) () -> Void

public func setEventHandler(qos: DispatchQoS = .unspecified, flags: DispatchWorkItemFlags = [], handler: DispatchSourceHandler?) {
if #available(OSX 10.10, iOS 8.0, *),
if #available(macOS 10.10, iOS 8.0, *),
let h = handler,
qos != .unspecified || !flags.isEmpty {
let item = DispatchWorkItem(qos: qos, flags: flags, block: h)
Expand All @@ -33,7 +33,7 @@ public extension DispatchSourceProtocol {
}

public func setCancelHandler(qos: DispatchQoS = .unspecified, flags: DispatchWorkItemFlags = [], handler: DispatchSourceHandler?) {
if #available(OSX 10.10, iOS 8.0, *),
if #available(macOS 10.10, iOS 8.0, *),
let h = handler,
qos != .unspecified || !flags.isEmpty {
let item = DispatchWorkItem(qos: qos, flags: flags, block: h)
Expand All @@ -49,7 +49,7 @@ public extension DispatchSourceProtocol {
}

public func setRegistrationHandler(qos: DispatchQoS = .unspecified, flags: DispatchWorkItemFlags = [], handler: DispatchSourceHandler?) {
if #available(OSX 10.10, iOS 8.0, *),
if #available(macOS 10.10, iOS 8.0, *),
let h = handler,
qos != .unspecified || !flags.isEmpty {
let item = DispatchWorkItem(qos: qos, flags: flags, block: h)
Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/SDK/Foundation/Calendar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ public struct Calendar : Hashable, Equatable, ReferenceConvertible, _MutableBoxi
}

internal static func _toNSCalendarIdentifier(_ identifier : Identifier) -> NSCalendar.Identifier {
if #available(OSX 10.10, iOS 8.0, *) {
if #available(macOS 10.10, iOS 8.0, *) {
let identifierMap : [Identifier : NSCalendar.Identifier] =
[.gregorian : .gregorian,
.buddhist : .buddhist,
Expand Down Expand Up @@ -1010,7 +1010,7 @@ public struct Calendar : Hashable, Equatable, ReferenceConvertible, _MutableBoxi
}

internal static func _fromNSCalendarIdentifier(_ identifier : NSCalendar.Identifier) -> Identifier {
if #available(OSX 10.10, iOS 8.0, *) {
if #available(macOS 10.10, iOS 8.0, *) {
let identifierMap : [NSCalendar.Identifier : Identifier] =
[.gregorian : .gregorian,
.buddhist : .buddhist,
Expand Down
12 changes: 6 additions & 6 deletions stdlib/public/SDK/Foundation/CharacterSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ public struct CharacterSet : ReferenceConvertible, Equatable, Hashable, SetAlgeb

/// Returns the character set for characters allowed in a user URL subcomponent.
public static var urlUserAllowed : CharacterSet {
if #available(OSX 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) {
if #available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) {
return CharacterSet(_uncopiedImmutableReference: _CFURLComponentsGetURLUserAllowedCharacterSet() as NSCharacterSet)
} else {
return CharacterSet(_uncopiedImmutableReference: _NSURLComponentsGetURLUserAllowedCharacterSet() as! NSCharacterSet)
Expand All @@ -526,7 +526,7 @@ public struct CharacterSet : ReferenceConvertible, Equatable, Hashable, SetAlgeb

/// Returns the character set for characters allowed in a password URL subcomponent.
public static var urlPasswordAllowed : CharacterSet {
if #available(OSX 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) {
if #available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) {
return CharacterSet(_uncopiedImmutableReference: _CFURLComponentsGetURLPasswordAllowedCharacterSet() as NSCharacterSet)
} else {
return CharacterSet(_uncopiedImmutableReference: _NSURLComponentsGetURLPasswordAllowedCharacterSet() as! NSCharacterSet)
Expand All @@ -535,7 +535,7 @@ public struct CharacterSet : ReferenceConvertible, Equatable, Hashable, SetAlgeb

/// Returns the character set for characters allowed in a host URL subcomponent.
public static var urlHostAllowed : CharacterSet {
if #available(OSX 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) {
if #available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) {
return CharacterSet(_uncopiedImmutableReference: _CFURLComponentsGetURLHostAllowedCharacterSet() as NSCharacterSet)
} else {
return CharacterSet(_uncopiedImmutableReference: _NSURLComponentsGetURLHostAllowedCharacterSet() as! NSCharacterSet)
Expand All @@ -544,7 +544,7 @@ public struct CharacterSet : ReferenceConvertible, Equatable, Hashable, SetAlgeb

/// Returns the character set for characters allowed in a path URL component.
public static var urlPathAllowed : CharacterSet {
if #available(OSX 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) {
if #available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) {
return CharacterSet(_uncopiedImmutableReference: _CFURLComponentsGetURLPathAllowedCharacterSet() as NSCharacterSet)
} else {
return CharacterSet(_uncopiedImmutableReference: _NSURLComponentsGetURLPathAllowedCharacterSet() as! NSCharacterSet)
Expand All @@ -553,7 +553,7 @@ public struct CharacterSet : ReferenceConvertible, Equatable, Hashable, SetAlgeb

/// Returns the character set for characters allowed in a query URL component.
public static var urlQueryAllowed : CharacterSet {
if #available(OSX 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) {
if #available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) {
return CharacterSet(_uncopiedImmutableReference: _CFURLComponentsGetURLQueryAllowedCharacterSet() as NSCharacterSet)
} else {
return CharacterSet(_uncopiedImmutableReference: _NSURLComponentsGetURLQueryAllowedCharacterSet() as! NSCharacterSet)
Expand All @@ -562,7 +562,7 @@ public struct CharacterSet : ReferenceConvertible, Equatable, Hashable, SetAlgeb

/// Returns the character set for characters allowed in a fragment URL component.
public static var urlFragmentAllowed : CharacterSet {
if #available(OSX 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) {
if #available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) {
return CharacterSet(_uncopiedImmutableReference: _CFURLComponentsGetURLFragmentAllowedCharacterSet() as NSCharacterSet)
} else {
return CharacterSet(_uncopiedImmutableReference: _NSURLComponentsGetURLFragmentAllowedCharacterSet() as! NSCharacterSet)
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/SDK/Foundation/Date.swift
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public struct Date : ReferenceConvertible, Comparable, Equatable {
public static let distantPast = Date(timeIntervalSinceReferenceDate: -63114076800.0)

public var hashValue: Int {
if #available(OSX 10.12, iOS 10.0, *) {
if #available(macOS 10.12, iOS 10.0, *) {
return Int(bitPattern: __CFHashDouble(_time))
} else { // 10.11 and previous behavior fallback; this must allocate a date to reference the hash value and then throw away the reference
return NSDate(timeIntervalSinceReferenceDate: _time).hash
Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/SDK/Foundation/JSONEncoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ extension _JSONEncoder {
return NSNumber(value: 1000.0 * date.timeIntervalSince1970)

case .iso8601:
if #available(OSX 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) {
if #available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) {
return NSString(string: _iso8601Formatter.string(from: date))
} else {
fatalError("ISO8601DateFormatter is unavailable on this platform.")
Expand Down Expand Up @@ -2289,7 +2289,7 @@ extension _JSONDecoder {
return Date(timeIntervalSince1970: double / 1000.0)

case .iso8601:
if #available(OSX 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) {
if #available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *) {
let string = try self.unbox(value, as: String.self)!
guard let date = _iso8601Formatter.date(from: string) else {
throw DecodingError.dataCorrupted(DecodingError.Context(codingPath: self.codingPath, debugDescription: "Expected date string to be ISO8601-formatted."))
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/SDK/Foundation/NSError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public func _getErrorDefaultUserInfo<T: Error>(_ error: T)

// If the OS supports user info value providers, use those
// to lazily populate the user-info dictionary for this domain.
if #available(OSX 10.11, iOS 9.0, tvOS 9.0, watchOS 2.0, *) {
if #available(macOS 10.11, iOS 9.0, tvOS 9.0, watchOS 2.0, *) {
// Note: the Cocoa error domain specifically excluded from
// user-info value providers.
let domain = error._domain
Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/SDK/Foundation/NSStringAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1638,7 +1638,7 @@ extension StringProtocol where Index == String.Index {
/// Equivalent to `self.rangeOfString(other) != nil`
public func contains<T : StringProtocol>(_ other: T) -> Bool {
let r = self.range(of: other) != nil
if #available(OSX 10.10, iOS 8.0, *) {
if #available(macOS 10.10, iOS 8.0, *) {
_sanityCheck(r == _ns.contains(other._ephemeralString))
}
return r
Expand All @@ -1661,7 +1661,7 @@ extension StringProtocol where Index == String.Index {
let r = self.range(
of: other, options: .caseInsensitive, locale: Locale.current
) != nil
if #available(OSX 10.10, iOS 8.0, *) {
if #available(macOS 10.10, iOS 8.0, *) {
_sanityCheck(r ==
_ns.localizedCaseInsensitiveContains(other._ephemeralString))
}
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/SDK/Foundation/URLComponents.swift
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ extension URLComponents : CustomStringConvertible, CustomDebugStringConvertible,
if let p = self.port { c.append((label: "port", value: p)) }

c.append((label: "path", value: self.path))
if #available(OSX 10.10, iOS 8.0, *) {
if #available(macOS 10.10, iOS 8.0, *) {
if let qi = self.queryItems { c.append((label: "queryItems", value: qi)) }
}
if let f = self.fragment { c.append((label: "fragment", value: f)) }
Expand Down