Skip to content

Commit dc5915c

Browse files
Replace stdlib and test/stdlib 9999 availability. (#26108)
* Replace stdlib and test/stdlib 9999 availability. macOS 9999 -> macOS 10.15 iOS 9999 -> iOS 13 tvOS 9999 -> tvOS 13 watchOS 9999 -> watchOS 6 * Restore the pre-10.15 version of public init?(_: NSRange, in: __shared String) We need this to allow master to work on 10.14 systems (in particular, to allow PR testing to work correctly without disabling back-deployment tests).
1 parent 0b1f0e4 commit dc5915c

19 files changed

+51
-32
lines changed

stdlib/public/Darwin/Compression/Compression.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import Foundation
1515
@_exported import Compression
1616

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

2121
/// LZFSE
@@ -51,7 +51,7 @@ public enum Algorithm: CaseIterable, RawRepresentable {
5151
}
5252

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

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

7979
/// Compression errors
80-
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
80+
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *)
8181
public enum FilterError: Error {
8282

8383
/// Filter failed to initialize,
@@ -90,7 +90,7 @@ public enum FilterError: Error {
9090
case invalidData
9191
}
9292

93-
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
93+
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *)
9494
extension compression_stream {
9595

9696
/// Initialize a compression_stream struct
@@ -112,7 +112,7 @@ extension compression_stream {
112112
}
113113
}
114114

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

227227
}
228228

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

232232
// Internal buffer to read bytes from a DataProtocol implementation

stdlib/public/Darwin/Foundation/NSRange.swift

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ extension Range where Bound == String.Index {
176176
_ range: NSRange, _genericIn string: __shared S
177177
) {
178178
// Corresponding stdlib version
179-
guard #available(macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, *) else {
179+
guard #available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) else {
180180
fatalError()
181181
}
182182
let u = string.utf16
@@ -193,9 +193,28 @@ extension Range where Bound == String.Index {
193193
}
194194

195195
public init?(_ range: NSRange, in string: __shared String) {
196-
self.init(range, _genericIn: string)
196+
if #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) {
197+
// When building for an OS that has the new stuff that supports
198+
// the generic version available, we just use that.
199+
self.init(range, _genericIn: string)
200+
} else {
201+
// Need to have the old version available to support testing a just-
202+
// built standard library on 10.14. We may want to figure out a more
203+
// principled way to handle this in the future, but this should keep
204+
// local and PR testing working.
205+
let u = string.utf16
206+
guard range.location != NSNotFound,
207+
let start = u.index(u.startIndex, offsetBy: range.location, limitedBy: u.endIndex),
208+
let end = u.index(u.startIndex, offsetBy: range.location + range.length, limitedBy: u.endIndex),
209+
let lowerBound = String.Index(start, within: string),
210+
let upperBound = String.Index(end, within: string)
211+
else { return nil }
212+
213+
self = lowerBound..<upperBound
214+
}
197215
}
198-
@available(macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, *)
216+
217+
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
199218
public init?<S: StringProtocol>(_ range: NSRange, in string: __shared S) {
200219
self.init(range, _genericIn: string)
201220
}

stdlib/public/Darwin/Network/NWConnection.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public final class NWConnection : CustomDebugStringConvertible {
110110
/// Retrieve the maximum datagram size that can be sent
111111
/// on the connection. Any datagrams sent should be less
112112
/// than or equal to this size.
113-
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
113+
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *)
114114
public var maximumDatagramSize: Int {
115115
get {
116116
return Int(nw_connection_get_maximum_datagram_size(self.nw))

stdlib/public/core/StringIndexConversions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ extension String.Index {
103103
/// `sourcePosition` must be a valid index of at least one of the views
104104
/// of `target`.
105105
/// - target: The string referenced by the resulting index.
106-
@available(macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, *)
106+
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
107107
public init?<S: StringProtocol>(
108108
_ sourcePosition: String.Index, within target: S
109109
) {

stdlib/public/core/UnicodeScalar.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ extension Unicode.Scalar.UTF16View : RandomAccessCollection {
435435
}
436436

437437
extension Unicode.Scalar {
438-
@available(macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, *)
438+
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
439439
@frozen
440440
public struct UTF8View {
441441
@inlinable
@@ -446,12 +446,12 @@ extension Unicode.Scalar {
446446
internal var value: Unicode.Scalar
447447
}
448448

449-
@available(macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, *)
449+
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
450450
@inlinable
451451
public var utf8: UTF8View { return UTF8View(value: self) }
452452
}
453453

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

test/stdlib/Character.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ UnicodeScalarTests.test("LosslessStringConvertible") {
417417
checkLosslessStringConvertible((0...127).map { UnicodeScalar(Int($0))! })
418418
}
419419

420-
if #available(macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, *) {
420+
if #available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) {
421421
UnicodeScalarTests.test("Views") {
422422
let scalars = baseScalars + continuingScalars
423423
for scalar in scalars {

test/stdlib/Compression.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class DataSource {
2929

3030
}
3131

32-
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
32+
@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *)
3333
func ofiltercompress_ifilterdecompress(
3434
_ contents: Data, using algo: Algorithm
3535
) throws -> Bool {
@@ -61,7 +61,7 @@ func ofiltercompress_ifilterdecompress(
6161
return contents == decompressed
6262
}
6363

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

114114
let tests = TestSuite("Compression")
115115

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

118118
do {
119119
for blockLength in [0, 1, 2, 5, 10, 100] {

test/stdlib/Inputs/CommonArrayTests.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ ${Suite}.test("${ArrayType}/init(unsafeUninitializedCapacity:...:)/validCount")
572572
}
573573

574574
${Suite}.test("${ArrayType}/init(unsafeUninitializedCapacity:...:)/reassignBuffer") {
575-
guard #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) else {
575+
guard #available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) else {
576576
// When back-deployed to 5.0, this coding error does not get detected.
577577
return
578578
}

test/stdlib/KVOKeyPaths.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ print("target removed")
123123

124124
// The following tests are only expected to pass when running with the
125125
// Swift 5.1 and later libraries.
126-
if #available(iOS 9999, macOS 9999, tvOS 9999, watchOS 9999, *) {
126+
if #available(iOS 13, macOS 10.15, tvOS 13, watchOS 6, *) {
127127
print("-check-prefix=CHECK-51")
128128
} else {
129129
print("-check-prefix=DONT-CHECK")

test/stdlib/StringBridge.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ StringBridgeTests.test("Tagged NSString") {
7777

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

8282
// NOTE: Using hard-coded literals to directly construct NSStrings
8383
let ns1 = "A" as NSString

test/stdlib/StringIndex.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ StringIndexTests.test("Scalar Align UTF-8 indices") {
200200
#if _runtime(_ObjC)
201201
import Foundation
202202
StringIndexTests.test("String.Index(_:within) / Range<String.Index>(_:in:)") {
203-
guard #available(macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, *) else {
203+
guard #available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) else {
204204
return
205205
}
206206

@@ -308,7 +308,7 @@ StringIndexTests.test("Exhaustive Index Interchange") {
308308
file: String = #file,
309309
line: UInt = #line
310310
) {
311-
guard #available(macOS 9999, iOS 9999, tvOS 9999, watchOS 9999, *) else {
311+
guard #available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) else {
312312
return
313313
}
314314

@@ -461,4 +461,4 @@ StringIndexTests.test("Exhaustive Index Interchange") {
461461
#endif // _runtime(_ObjC)
462462
}
463463

464-
runAllTests()
464+
runAllTests()

test/stdlib/TestAffineTransform.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ class TestAffineTransform : TestAffineTransformSuper {
316316
}
317317

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

321321
// the transforms are made up and the values don't matter
322322
let a = AffineTransform(m11: 1.0, m12: 2.5, m21: 66.2, m22: 40.2, tX: -5.5, tY: 3.7)

test/stdlib/TestDateInterval.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class TestDateInterval : TestDateIntervalSuper {
6666
}
6767

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

7171
let start1a = dateWithString("2019-04-04 17:09:23 -0700")
7272
let start1b = dateWithString("2019-04-04 17:09:23 -0700")

test/stdlib/TestIndexPath.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ class TestIndexPath: TestIndexPathSuper {
222222
}
223223

224224
func testHashing() {
225-
guard #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) else { return }
225+
guard #available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) else { return }
226226
let samples: [IndexPath] = [
227227
[],
228228
[1],

test/stdlib/TestMeasurement.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class TestMeasurement : TestMeasurementSuper {
152152
}
153153

154154
func testHashing() {
155-
guard #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) else { return }
155+
guard #available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) else { return }
156156
let lengths: [[Measurement<UnitLength>]] = [
157157
[
158158
Measurement(value: 5, unit: UnitLength.kilometers),

test/stdlib/TestNotification.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class TestNotification : TestNotificationSuper {
3434
}
3535

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

3939
let o1 = NSObject()
4040
let o2 = NSObject()

test/stdlib/TestPlistEncoder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ PropertyListEncoderTests.test("testEncodingTopLevelDeepStructuredType") { TestPr
874874
PropertyListEncoderTests.test("testEncodingClassWhichSharesEncoderWithSuper") { TestPropertyListEncoder().testEncodingClassWhichSharesEncoderWithSuper() }
875875
PropertyListEncoderTests.test("testEncodingTopLevelNullableType") { TestPropertyListEncoder().testEncodingTopLevelNullableType() }
876876
PropertyListEncoderTests.test("testEncodingMultipleNestedContainersWithTheSameTopLevelKey") {
877-
if #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) {
877+
if #available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) {
878878
TestPropertyListEncoder().testEncodingMultipleNestedContainersWithTheSameTopLevelKey()
879879
}
880880
}

test/stdlib/TestUUID.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class TestUUID : TestUUIDSuper {
8585
}
8686

8787
func test_hash() {
88-
guard #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) else { return }
88+
guard #available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) else { return }
8989
let values: [UUID] = [
9090
// This list takes a UUID and tweaks every byte while
9191
// leaving the version/variant intact.

test/stdlib/Unicode.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ typealias UTF16 = Unicode.UTF16
6363
typealias UTF32 = Unicode.UTF32
6464

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

0 commit comments

Comments
 (0)