Skip to content

Replace stdlib and test/stdlib 9999 availability. #26108

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 2 commits into from
Jul 12, 2019
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
12 changes: 6 additions & 6 deletions stdlib/public/Darwin/Compression/Compression.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Foundation
@_exported import Compression

/// Compression algorithms, wraps the C API constants.
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *)
public enum Algorithm: CaseIterable, RawRepresentable {

/// LZFSE
Expand Down Expand Up @@ -51,7 +51,7 @@ public enum Algorithm: CaseIterable, RawRepresentable {
}

/// Compression filter direction of operation, compress/decompress
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *)
public enum FilterOperation: RawRepresentable {

/// Compress raw data to a compressed payload
Expand All @@ -77,7 +77,7 @@ public enum FilterOperation: RawRepresentable {
}

/// Compression errors
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *)
public enum FilterError: Error {

/// Filter failed to initialize,
Expand All @@ -90,7 +90,7 @@ public enum FilterError: Error {
case invalidData
}

@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *)
extension compression_stream {

/// Initialize a compression_stream struct
Expand All @@ -112,7 +112,7 @@ extension compression_stream {
}
}

@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *)
public class OutputFilter {
private var _stream: compression_stream
private var _buf: UnsafeMutablePointer<UInt8>
Expand Down Expand Up @@ -226,7 +226,7 @@ public class OutputFilter {

}

@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *)
public class InputFilter<D: DataProtocol> {

// Internal buffer to read bytes from a DataProtocol implementation
Expand Down
25 changes: 22 additions & 3 deletions stdlib/public/Darwin/Foundation/NSRange.swift
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ extension Range where Bound == String.Index {
_ range: NSRange, _genericIn string: __shared S
) {
// Corresponding stdlib version
guard #available(macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, *) else {
guard #available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) else {
fatalError()
}
let u = string.utf16
Expand All @@ -193,9 +193,28 @@ extension Range where Bound == String.Index {
}

public init?(_ range: NSRange, in string: __shared String) {
self.init(range, _genericIn: string)
if #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) {
// When building for an OS that has the new stuff that supports
// the generic version available, we just use that.
self.init(range, _genericIn: string)
} else {
// Need to have the old version available to support testing a just-
// built standard library on 10.14. We may want to figure out a more
// principled way to handle this in the future, but this should keep
// local and PR testing working.
let u = string.utf16
guard range.location != NSNotFound,
let start = u.index(u.startIndex, offsetBy: range.location, limitedBy: u.endIndex),
let end = u.index(u.startIndex, offsetBy: range.location + range.length, limitedBy: u.endIndex),
let lowerBound = String.Index(start, within: string),
let upperBound = String.Index(end, within: string)
else { return nil }

self = lowerBound..<upperBound
}
}
@available(macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, *)

@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public init?<S: StringProtocol>(_ range: NSRange, in string: __shared S) {
self.init(range, _genericIn: string)
}
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/Darwin/Network/NWConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public final class NWConnection : CustomDebugStringConvertible {
/// Retrieve the maximum datagram size that can be sent
/// on the connection. Any datagrams sent should be less
/// than or equal to this size.
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *)
public var maximumDatagramSize: Int {
get {
return Int(nw_connection_get_maximum_datagram_size(self.nw))
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/core/StringIndexConversions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ extension String.Index {
/// `sourcePosition` must be a valid index of at least one of the views
/// of `target`.
/// - target: The string referenced by the resulting index.
@available(macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, *)
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public init?<S: StringProtocol>(
_ sourcePosition: String.Index, within target: S
) {
Expand Down
6 changes: 3 additions & 3 deletions stdlib/public/core/UnicodeScalar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ extension Unicode.Scalar.UTF16View : RandomAccessCollection {
}

extension Unicode.Scalar {
@available(macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, *)
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
@frozen
public struct UTF8View {
@inlinable
Expand All @@ -446,12 +446,12 @@ extension Unicode.Scalar {
internal var value: Unicode.Scalar
}

@available(macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, *)
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
@inlinable
public var utf8: UTF8View { return UTF8View(value: self) }
}

@available(macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, *)
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
extension Unicode.Scalar.UTF8View : RandomAccessCollection {
public typealias Indices = Range<Int>

Expand Down
2 changes: 1 addition & 1 deletion test/stdlib/Character.swift
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ UnicodeScalarTests.test("LosslessStringConvertible") {
checkLosslessStringConvertible((0...127).map { UnicodeScalar(Int($0))! })
}

if #available(macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, *) {
if #available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) {
UnicodeScalarTests.test("Views") {
let scalars = baseScalars + continuingScalars
for scalar in scalars {
Expand Down
6 changes: 3 additions & 3 deletions test/stdlib/Compression.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class DataSource {

}

@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *)
func ofiltercompress_ifilterdecompress(
_ contents: Data, using algo: Algorithm
) throws -> Bool {
Expand Down Expand Up @@ -61,7 +61,7 @@ func ofiltercompress_ifilterdecompress(
return contents == decompressed
}

@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *)
func ifiltercompress_ofilterdecompress(
_ contents: Data, using algo: Algorithm
) throws -> Bool {
Expand Down Expand Up @@ -113,7 +113,7 @@ func randomString(withBlockLength n: Int) -> String {

let tests = TestSuite("Compression")

if #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) {
if #available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) {

do {
for blockLength in [0, 1, 2, 5, 10, 100] {
Expand Down
2 changes: 1 addition & 1 deletion test/stdlib/Inputs/CommonArrayTests.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ ${Suite}.test("${ArrayType}/init(unsafeUninitializedCapacity:...:)/validCount")
}

${Suite}.test("${ArrayType}/init(unsafeUninitializedCapacity:...:)/reassignBuffer") {
guard #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) else {
guard #available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) else {
// When back-deployed to 5.0, this coding error does not get detected.
return
}
Expand Down
2 changes: 1 addition & 1 deletion test/stdlib/KVOKeyPaths.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ print("target removed")

// The following tests are only expected to pass when running with the
// Swift 5.1 and later libraries.
if #available(iOS 9999, macOS 9999, tvOS 9999, watchOS 9999, *) {
if #available(iOS 13, macOS 10.15, tvOS 13, watchOS 6, *) {
print("-check-prefix=CHECK-51")
} else {
print("-check-prefix=DONT-CHECK")
Expand Down
2 changes: 1 addition & 1 deletion test/stdlib/StringBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ StringBridgeTests.test("Tagged NSString") {

func returnOne<T>(_ t: T) -> Int { return 1 }
StringBridgeTests.test("Character from NSString") {
guard #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) else { return }
guard #available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) else { return }

// NOTE: Using hard-coded literals to directly construct NSStrings
let ns1 = "A" as NSString
Expand Down
6 changes: 3 additions & 3 deletions test/stdlib/StringIndex.swift
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ StringIndexTests.test("Scalar Align UTF-8 indices") {
#if _runtime(_ObjC)
import Foundation
StringIndexTests.test("String.Index(_:within) / Range<String.Index>(_:in:)") {
guard #available(macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, *) else {
guard #available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) else {
return
}

Expand Down Expand Up @@ -308,7 +308,7 @@ StringIndexTests.test("Exhaustive Index Interchange") {
file: String = #file,
line: UInt = #line
) {
guard #available(macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, *) else {
guard #available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) else {
return
}

Expand Down Expand Up @@ -461,4 +461,4 @@ StringIndexTests.test("Exhaustive Index Interchange") {
#endif // _runtime(_ObjC)
}

runAllTests()
runAllTests()
2 changes: 1 addition & 1 deletion test/stdlib/TestAffineTransform.swift
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ class TestAffineTransform : TestAffineTransformSuper {
}

func test_hashing() {
guard #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) else { return }
guard #available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) else { return }

// the transforms are made up and the values don't matter
let a = AffineTransform(m11: 1.0, m12: 2.5, m21: 66.2, m22: 40.2, tX: -5.5, tY: 3.7)
Expand Down
2 changes: 1 addition & 1 deletion test/stdlib/TestDateInterval.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class TestDateInterval : TestDateIntervalSuper {
}

func test_hashing() {
guard #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) else { return }
guard #available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) else { return }

let start1a = dateWithString("2019-04-04 17:09:23 -0700")
let start1b = dateWithString("2019-04-04 17:09:23 -0700")
Expand Down
2 changes: 1 addition & 1 deletion test/stdlib/TestIndexPath.swift
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class TestIndexPath: TestIndexPathSuper {
}

func testHashing() {
guard #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) else { return }
guard #available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) else { return }
let samples: [IndexPath] = [
[],
[1],
Expand Down
2 changes: 1 addition & 1 deletion test/stdlib/TestMeasurement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class TestMeasurement : TestMeasurementSuper {
}

func testHashing() {
guard #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) else { return }
guard #available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) else { return }
let lengths: [[Measurement<UnitLength>]] = [
[
Measurement(value: 5, unit: UnitLength.kilometers),
Expand Down
2 changes: 1 addition & 1 deletion test/stdlib/TestNotification.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class TestNotification : TestNotificationSuper {
}

func test_hashing() {
guard #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) else { return }
guard #available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) else { return }

let o1 = NSObject()
let o2 = NSObject()
Expand Down
2 changes: 1 addition & 1 deletion test/stdlib/TestPlistEncoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ PropertyListEncoderTests.test("testEncodingTopLevelDeepStructuredType") { TestPr
PropertyListEncoderTests.test("testEncodingClassWhichSharesEncoderWithSuper") { TestPropertyListEncoder().testEncodingClassWhichSharesEncoderWithSuper() }
PropertyListEncoderTests.test("testEncodingTopLevelNullableType") { TestPropertyListEncoder().testEncodingTopLevelNullableType() }
PropertyListEncoderTests.test("testEncodingMultipleNestedContainersWithTheSameTopLevelKey") {
if #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) {
if #available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) {
TestPropertyListEncoder().testEncodingMultipleNestedContainersWithTheSameTopLevelKey()
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/stdlib/TestUUID.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class TestUUID : TestUUIDSuper {
}

func test_hash() {
guard #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) else { return }
guard #available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) else { return }
let values: [UUID] = [
// This list takes a UUID and tweaks every byte while
// leaving the version/variant intact.
Expand Down
2 changes: 1 addition & 1 deletion test/stdlib/Unicode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ typealias UTF16 = Unicode.UTF16
typealias UTF32 = Unicode.UTF32

UnicodeAPIs.test("UTF-8 and UTF-16 queries") {
guard #available(macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, *) else {
guard #available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) else {
return
}
let str = "abéÏ01😓🎃👨‍👨‍👧‍👦アイウエオ"
Expand Down