Skip to content

[gardening] Prefer macOS over OSX for #available #1475

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
4 changes: 2 additions & 2 deletions Foundation/Calendar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,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 @@ -1091,7 +1091,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
2 changes: 1 addition & 1 deletion Foundation/Data.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import _SwiftFoundationOverlayShims
import _SwiftCoreFoundationOverlayShims

internal func __NSDataIsCompact(_ data: NSData) -> Bool {
if #available(OSX 10.10, iOS 9.0, tvOS 9.0, watchOS 2.0, *) {
if #available(macOS 10.10, iOS 9.0, tvOS 9.0, watchOS 2.0, *) {
return data._isCompact()
} else {
var compact = true
Expand Down
6 changes: 3 additions & 3 deletions Foundation/HTTPCookieStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ open class HTTPCookieStorage: NSObject {
private var _allCookies: [String: HTTPCookie]
private var allCookies: [String: HTTPCookie] {
get {
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, *) {
dispatchPrecondition(condition: DispatchPredicate.onQueue(self.syncQ))
}
return self._allCookies
}
set {
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, *) {
dispatchPrecondition(condition: DispatchPredicate.onQueue(self.syncQ))
}
self._allCookies = newValue
Expand Down Expand Up @@ -200,7 +200,7 @@ open class HTTPCookieStorage: NSObject {
}

private func updatePersistentStore() {
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, *) {
dispatchPrecondition(condition: DispatchPredicate.onQueue(self.syncQ))
}

Expand Down
4 changes: 2 additions & 2 deletions Foundation/JSONEncoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,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 @@ -2023,7 +2023,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
4 changes: 2 additions & 2 deletions 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 Foundation/URLComponents.swift
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,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
4 changes: 2 additions & 2 deletions TestFoundation/TestJSONEncoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class TestJSONEncoder : XCTestCase {
let expectedJSON = "{\"email\":\"[email protected]\",\"name\":\"Johnny Appleseed\"}".data(using: .utf8)!
let person = Person.testValue
#if os(OSX) || DARWIN_COMPATIBILITY_TESTS
if #available(OSX 10.13, iOS 11.0, watchOS 4.0, tvOS 11.0, *) {
if #available(macOS 10.13, iOS 11.0, watchOS 4.0, tvOS 11.0, *) {
_testRoundTrip(of: person, expectedJSON: expectedJSON, outputFormatting: [.sortedKeys])
}
#else
Expand All @@ -120,7 +120,7 @@ class TestJSONEncoder : XCTestCase {
let expectedJSON = "{\n \"email\" : \"[email protected]\",\n \"name\" : \"Johnny Appleseed\"\n}".data(using: .utf8)!
let person = Person.testValue
#if os(OSX) || DARWIN_COMPATIBILITY_TESTS
if #available(OSX 10.13, iOS 11.0, watchOS 4.0, tvOS 11.0, *) {
if #available(macOS 10.13, iOS 11.0, watchOS 4.0, tvOS 11.0, *) {
_testRoundTrip(of: person, expectedJSON: expectedJSON, outputFormatting: [.prettyPrinted, .sortedKeys])
}
#else
Expand Down
2 changes: 1 addition & 1 deletion TestFoundation/TestJSONSerialization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1475,7 +1475,7 @@ extension TestJSONSerialization {
let dict3 = ["c": ["c":1,"b":1,"a":1],"b":["c":1,"b":1,"a":1],"a":["c":1,"b":1,"a":1]]

#if DARWIN_COMPATIBILITY_TESTS
if #available(OSX 10.13, *) {
if #available(macOS 10.13, *) {
XCTAssertEqual(try trySerialize(dict1, options: .sortedKeys), "{\"q\":1,\"r\":1,\"s\":1,\"t\":1,\"u\":1,\"v\":1,\"w\":1,\"x\":1,\"y\":1,\"z\":1}")
XCTAssertEqual(try trySerialize(dict2, options: .sortedKeys), "{\"a\":1,\"aa\":1,\"aaa\":1,\"aaaa\":1}")
XCTAssertEqual(try trySerialize(dict3, options: .sortedKeys), "{\"a\":{\"a\":1,\"b\":1,\"c\":1},\"b\":{\"a\":1,\"b\":1,\"c\":1},\"c\":{\"a\":1,\"b\":1,\"c\":1}}")
Expand Down
2 changes: 1 addition & 1 deletion TestFoundation/TestNSArray.swift
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ class TestNSArray : XCTestCase {
let url = URL(fileURLWithPath: testFile)
let data2: NSArray
#if DARWIN_COMPATIBILITY_TESTS
if #available(OSX 10.13, *) {
if #available(macOS 10.13, *) {
try data.write(to: url)
data2 = try NSArray(contentsOf: url, error: ())
} else {
Expand Down