Skip to content

Commit 8ed81ae

Browse files
committed
[stdlib] Adopt availability macros
1 parent 8e154a4 commit 8ed81ae

24 files changed

+57
-57
lines changed

stdlib/public/core/AnyHashable.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ extension AnyHashable: CustomReflectable {
262262
}
263263
#endif
264264

265-
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
265+
@available(SwiftStdlib 5.5, *)
266266
extension AnyHashable: _HasCustomAnyHashableRepresentation {
267267
}
268268

stdlib/public/core/Assert.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ internal func _internalInvariant_5_1(
311311
// FIXME: The below won't run the assert on 5.1 stdlib if testing on older
312312
// OSes, which means that testing may not test the assertion. We need a real
313313
// solution to this.
314-
guard #available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) else { return }
314+
guard #available(SwiftStdlib 5.1, *) else { return }
315315
_internalInvariant(condition(), message, file: file, line: line)
316316
#endif
317317
}

stdlib/public/core/BridgeObjectiveC.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public protocol _ObjectiveCBridgeable {
8888
// Note: This function is not intended to be called from Swift. The
8989
// availability information here is perfunctory; this function isn't considered
9090
// part of the Stdlib's Swift ABI.
91-
@available(macOS 10.15.4, iOS 13.4, watchOS 6.2, tvOS 13.4, *)
91+
@available(SwiftStdlib 5.2, *)
9292
@_cdecl("_SwiftCreateBridgedArray")
9393
@usableFromInline
9494
internal func _SwiftCreateBridgedArray_DoNotCall(
@@ -103,7 +103,7 @@ internal func _SwiftCreateBridgedArray_DoNotCall(
103103
// Note: This function is not intended to be called from Swift. The
104104
// availability information here is perfunctory; this function isn't considered
105105
// part of the Stdlib's Swift ABI.
106-
@available(macOS 10.15.4, iOS 13.4, watchOS 6.2, tvOS 13.4, *)
106+
@available(SwiftStdlib 5.2, *)
107107
@_cdecl("_SwiftCreateBridgedMutableArray")
108108
@usableFromInline
109109
internal func _SwiftCreateBridgedMutableArray_DoNotCall(

stdlib/public/core/CTypes.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public typealias CLongLong = Int64
5858

5959
#if !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64))
6060
/// The C '_Float16' type.
61-
@available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
61+
@available(SwiftStdlib 5.3, *)
6262
public typealias CFloat16 = Float16
6363
#endif
6464

stdlib/public/core/Codable.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -4732,7 +4732,7 @@ extension RawRepresentable where RawValue == Float, Self: Decodable {
47324732
}
47334733

47344734
#if !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64))
4735-
@available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
4735+
@available(SwiftStdlib 5.3, *)
47364736
extension Float16: Codable {
47374737
/// Creates a new instance by decoding from the given decoder.
47384738
///

stdlib/public/core/CollectionDifference.swift

+15-15
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
/// A collection of insertions and removals that describe the difference
1414
/// between two ordered collection states.
15-
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
15+
@available(SwiftStdlib 5.1, *)
1616
public struct CollectionDifference<ChangeElement> {
1717
/// A single change to a collection.
1818
@frozen
@@ -233,7 +233,7 @@ public struct CollectionDifference<ChangeElement> {
233233
/// }
234234
/// }
235235
/// ```
236-
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
236+
@available(SwiftStdlib 5.1, *)
237237
extension CollectionDifference: Collection {
238238
public typealias Element = Change
239239

@@ -281,7 +281,7 @@ extension CollectionDifference: Collection {
281281
}
282282
}
283283

284-
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
284+
@available(SwiftStdlib 5.1, *)
285285
extension CollectionDifference.Index: Equatable {
286286
@inlinable
287287
public static func == (
@@ -292,7 +292,7 @@ extension CollectionDifference.Index: Equatable {
292292
}
293293
}
294294

295-
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
295+
@available(SwiftStdlib 5.1, *)
296296
extension CollectionDifference.Index: Comparable {
297297
@inlinable
298298
public static func < (
@@ -303,27 +303,27 @@ extension CollectionDifference.Index: Comparable {
303303
}
304304
}
305305

306-
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
306+
@available(SwiftStdlib 5.1, *)
307307
extension CollectionDifference.Index: Hashable {
308308
@inlinable
309309
public func hash(into hasher: inout Hasher) {
310310
hasher.combine(_offset)
311311
}
312312
}
313313

314-
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
314+
@available(SwiftStdlib 5.1, *)
315315
extension CollectionDifference.Change: Equatable where ChangeElement: Equatable {}
316316

317-
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
317+
@available(SwiftStdlib 5.1, *)
318318
extension CollectionDifference: Equatable where ChangeElement: Equatable {}
319319

320-
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
320+
@available(SwiftStdlib 5.1, *)
321321
extension CollectionDifference.Change: Hashable where ChangeElement: Hashable {}
322322

323-
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
323+
@available(SwiftStdlib 5.1, *)
324324
extension CollectionDifference: Hashable where ChangeElement: Hashable {}
325325

326-
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
326+
@available(SwiftStdlib 5.1, *)
327327
extension CollectionDifference where ChangeElement: Hashable {
328328
/// Returns a new collection difference with associations between individual
329329
/// elements that have been removed and inserted only once.
@@ -380,7 +380,7 @@ extension CollectionDifference where ChangeElement: Hashable {
380380
}
381381
}
382382

383-
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
383+
@available(SwiftStdlib 5.1, *)
384384
extension CollectionDifference.Change: Codable where ChangeElement: Codable {
385385
private enum _CodingKeys: String, CodingKey {
386386
case offset
@@ -417,12 +417,12 @@ extension CollectionDifference.Change: Codable where ChangeElement: Codable {
417417
}
418418
}
419419

420-
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
420+
@available(SwiftStdlib 5.1, *)
421421
extension CollectionDifference: Codable where ChangeElement: Codable {}
422422

423-
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
423+
@available(SwiftStdlib 5.1, *)
424424
extension CollectionDifference: Sendable where ChangeElement: Sendable { }
425-
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
425+
@available(SwiftStdlib 5.1, *)
426426
extension CollectionDifference.Change: Sendable where ChangeElement: Sendable { }
427-
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
427+
@available(SwiftStdlib 5.1, *)
428428
extension CollectionDifference.Index: Sendable where ChangeElement: Sendable { }

stdlib/public/core/Diffing.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
// MARK: Diff application to RangeReplaceableCollection
1414

15-
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
15+
@available(SwiftStdlib 5.1, *)
1616
extension CollectionDifference {
1717
fileprivate func _fastEnumeratedApply(
1818
_ consume: (Change) throws -> Void
@@ -67,7 +67,7 @@ extension RangeReplaceableCollection {
6767
///
6868
/// - Complexity: O(*n* + *c*), where *n* is `self.count` and *c* is the
6969
/// number of changes contained by the parameter.
70-
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
70+
@available(SwiftStdlib 5.1, *)
7171
public func applying(_ difference: CollectionDifference<Element>) -> Self? {
7272

7373
func append(
@@ -142,7 +142,7 @@ extension BidirectionalCollection {
142142
/// - Complexity: Worst case performance is O(*n* * *m*), where *n* is the
143143
/// count of this collection and *m* is `other.count`. You can expect
144144
/// faster execution when the collections share many common elements.
145-
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
145+
@available(SwiftStdlib 5.1, *)
146146
public func difference<C: BidirectionalCollection>(
147147
from other: C,
148148
by areEquivalent: (C.Element, Element) -> Bool
@@ -169,7 +169,7 @@ extension BidirectionalCollection where Element: Equatable {
169169
/// count of this collection and *m* is `other.count`. You can expect
170170
/// faster execution when the collections share many common elements, or
171171
/// if `Element` conforms to `Hashable`.
172-
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
172+
@available(SwiftStdlib 5.1, *)
173173
public func difference<C: BidirectionalCollection>(
174174
from other: C
175175
) -> CollectionDifference<Element> where C.Element == Self.Element {
@@ -224,7 +224,7 @@ private struct _V {
224224
}
225225
}
226226

227-
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
227+
@available(SwiftStdlib 5.1, *)
228228
private func _myers<C,D>(
229229
from old: C, to new: D,
230230
using cmp: (C.Element, D.Element) -> Bool

stdlib/public/core/FloatingPoint.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1895,7 +1895,7 @@ extension BinaryFloatingPoint {
18951895
switch (Source.exponentBitCount, Source.significandBitCount) {
18961896
#if !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64))
18971897
case (5, 10):
1898-
guard #available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *) else {
1898+
guard #available(SwiftStdlib 5.3, *) else {
18991899
// Convert signaling NaN to quiet NaN by multiplying by 1.
19001900
self = Self._convert(from: value).value * 1
19011901
break

stdlib/public/core/FloatingPointParsing.swift.gyb

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ internal func _isspace_clocale(_ u: UTF16.CodeUnit) -> Bool {
4747
% end
4848

4949
%if bits == 16:
50-
@available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
50+
@available(SwiftStdlib 5.3, *)
5151
%end
5252
extension ${Self}: LosslessStringConvertible {
5353
/// Creates a new instance from the given string.
@@ -165,7 +165,7 @@ extension ${Self}: LosslessStringConvertible {
165165
%if bits == 16:
166166
self.init(Substring(text))
167167
%else:
168-
if #available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *) {
168+
if #available(SwiftStdlib 5.3, *) {
169169
self.init(Substring(text))
170170
} else {
171171
self = 0.0
@@ -195,7 +195,7 @@ extension ${Self}: LosslessStringConvertible {
195195
// In particular, we still have to export
196196
// _swift_stdlib_strtoXYZ_clocale()
197197
// as ABI to support old compiled code that still requires it.
198-
@available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
198+
@available(SwiftStdlib 5.3, *)
199199
public init?(_ text: Substring) {
200200
self = 0.0
201201
let success = withUnsafeMutablePointer(to: &self) { p -> Bool in

stdlib/public/core/FloatingPointTypes.swift.gyb

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ RawSignificand = 'UInt' + str(SignificandSize)
4040

4141
def Availability(bits):
4242
if bits == 16:
43-
return '@available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *)'
43+
return '@available(SwiftStdlib 5.3, *)'
4444
return ''
4545

4646
if Self == 'Float16':
@@ -1366,7 +1366,7 @@ internal struct _${Self}AnyHashableBox: _AnyHashableBox {
13661366
${SelfDocComment}
13671367
@frozen
13681368
% if bits == 16:
1369-
@available(macOS 11, iOS 14, tvOS 14, watchOS 7, *)
1369+
@available(SwiftStdlib 5.3, *)
13701370
@available(macOS, unavailable)
13711371
@available(macCatalyst, unavailable)
13721372
% else:
@@ -1385,7 +1385,7 @@ public struct ${Self} {
13851385
// from the implicit conformance emitted into the generated .swiftinterface
13861386
// file. See https://github.com/apple/swift/pull/36669 for details.
13871387
// FIXME: rdar://76092800
1388-
@available(macOS 11, iOS 14, tvOS 14, watchOS 7, *)
1388+
@available(SwiftStdlib 5.3, *)
13891389
@available(macOS, unavailable)
13901390
@available(macCatalyst, unavailable)
13911391
extension ${Self}: Sendable { }

stdlib/public/core/Identifiable.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
/// `ObjectIdentifier`), which is only guaranteed to remain unique for the
3939
/// lifetime of an object. If an object has a stronger notion of identity, it
4040
/// may be appropriate to provide a custom implementation.
41-
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
41+
@available(SwiftStdlib 5.1, *)
4242
public protocol Identifiable {
4343

4444
/// A type representing the stable identity of the entity associated with
@@ -49,7 +49,7 @@ public protocol Identifiable {
4949
var id: ID { get }
5050
}
5151

52-
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
52+
@available(SwiftStdlib 5.1, *)
5353
extension Identifiable where Self: AnyObject {
5454
public var id: ObjectIdentifier {
5555
return ObjectIdentifier(self)

stdlib/public/core/IntegerTypes.swift.gyb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1155,7 +1155,7 @@ public struct ${Self}
11551155
/// `source` must be representable in this type after rounding toward
11561156
/// zero.
11571157
% if FloatType == 'Float16':
1158-
@available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
1158+
@available(SwiftStdlib 5.3, *)
11591159
% end
11601160
@_transparent
11611161
public init(_ source: ${FloatType}) {
@@ -1193,7 +1193,7 @@ public struct ${Self}
11931193
///
11941194
/// - Parameter source: A floating-point value to convert to an integer.
11951195
% if FloatType == 'Float16':
1196-
@available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
1196+
@available(SwiftStdlib 5.3, *)
11971197
% end
11981198
@_transparent
11991199
public init?(exactly source: ${FloatType}) {

stdlib/public/core/Misc.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ func _typeName(_ type: Any.Type, qualified: Bool = true) -> String {
6464
UnsafeBufferPointer(start: stringPtr, count: count)).0
6565
}
6666

67-
@available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
67+
@available(SwiftStdlib 5.3, *)
6868
@_silgen_name("swift_getMangledTypeName")
6969
public func _getMangledTypeName(_ type: Any.Type)
7070
-> (UnsafePointer<UInt8>, Int)
7171

7272
/// Returns the mangled name for a given type.
73-
@available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
73+
@available(SwiftStdlib 5.3, *)
7474
public // SPI
7575
func _mangledTypeName(_ type: Any.Type) -> String? {
7676
let (stringPtr, count) = _getMangledTypeName(type)

stdlib/public/core/Policy.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ extension Never: Error {}
3434

3535
extension Never: Equatable, Comparable, Hashable {}
3636

37-
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
37+
@available(SwiftStdlib 5.5, *)
3838
extension Never: Identifiable {
39-
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)
39+
@available(SwiftStdlib 5.5, *)
4040
public var id: Never {
4141
switch self {}
4242
}

stdlib/public/core/ReflectionMirror.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ extension Mirror {
188188
}
189189

190190
/// Options for calling `_forEachField(of:options:body:)`.
191-
@available(macOS 10.15.4, iOS 13.4, tvOS 13.4, watchOS 6.2, *)
191+
@available(SwiftStdlib 5.2, *)
192192
@_spi(Reflection)
193193
public struct _EachFieldOptions: OptionSet {
194194
public var rawValue: UInt32
@@ -211,7 +211,7 @@ public struct _EachFieldOptions: OptionSet {
211211
}
212212

213213
/// The metadata "kind" for a type.
214-
@available(macOS 10.15.4, iOS 13.4, tvOS 13.4, watchOS 6.2, *)
214+
@available(SwiftStdlib 5.2, *)
215215
@_spi(Reflection)
216216
public enum _MetadataKind: UInt {
217217
// With "flags":
@@ -259,7 +259,7 @@ public enum _MetadataKind: UInt {
259259
/// and the `_MetadataKind` of the field's type.
260260
/// - Returns: `true` if every invocation of `body` returns `true`; otherwise,
261261
/// `false`.
262-
@available(macOS 10.15.4, iOS 13.4, tvOS 13.4, watchOS 6.2, *)
262+
@available(SwiftStdlib 5.2, *)
263263
@discardableResult
264264
@_spi(Reflection)
265265
public func _forEachField(
@@ -302,7 +302,7 @@ public func _forEachField(
302302
/// and the `_MetadataKind` of the field's type.
303303
/// - Returns: `true` if every invocation of `body` returns `true`; otherwise,
304304
/// `false`.
305-
@available(macOS 11.3, iOS 14.5, tvOS 14.5, watchOS 7.4, *)
305+
@available(SwiftStdlib 5.4, *)
306306
@discardableResult
307307
@_spi(Reflection)
308308
public func _forEachFieldWithKeyPath<Root>(

stdlib/public/core/Runtime.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ internal func _float16ToStringImpl(
304304
_ debug: Bool
305305
) -> Int
306306

307-
@available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
307+
@available(SwiftStdlib 5.3, *)
308308
internal func _float16ToString(
309309
_ value: Float16,
310310
debug: Bool

stdlib/public/core/SIMDConcreteOperations.swift.gyb

+1-1
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ extension SIMD${n} where Scalar == ${Scalar} {
308308
% MaskExt = "Builtin.sext_" + VecPre + "Int1_" + VecPre + "Int" + str(bits)
309309
% if bits == 16:
310310
#if !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64))
311-
@available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
311+
@available(SwiftStdlib 5.3, *)
312312
% end
313313
extension SIMD${n} where Scalar == ${Scalar} {
314314
@_alwaysEmitIntoClient

stdlib/public/core/SIMDVectorTypes.swift.gyb

+1-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ extension ${Self}: SIMDScalar {
264264
%for (Self, bits) in [('Float16',16), ('Float',32), ('Double',64)]:
265265
% if bits == 16:
266266
#if !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64))
267-
@available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
267+
@available(SwiftStdlib 5.3, *)
268268
% end
269269
extension ${Self} : SIMDScalar {
270270

stdlib/public/core/String.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ extension String {
516516
/// memory with room for `capacity` UTF-8 code units, initializes
517517
/// that memory, and returns the number of initialized elements.
518518
@inline(__always)
519-
@available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
519+
@available(SwiftStdlib 5.3, *)
520520
public init(
521521
unsafeUninitializedCapacity capacity: Int,
522522
initializingUTF8With initializer: (

0 commit comments

Comments
 (0)