Skip to content

Commit 6d25565

Browse files
authored
Merge pull request swiftlang#39994 from lorentey/adopt-availability-macros
[stdlib] Adopt availability macros
2 parents bb0883d + 8ea88b7 commit 6d25565

File tree

115 files changed

+297
-293
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+297
-293
lines changed

lib/Parse/ParseDecl.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,6 +1632,9 @@ Parser::parseAvailabilityMacro(SmallVectorImpl<AvailabilitySpec *> &Specs) {
16321632
if (NameMatch == Map.end())
16331633
return makeParserSuccess(); // No match, it could be a standard platform.
16341634

1635+
SyntaxParsingContext VersionRestrictionContext(
1636+
SyntaxContext, SyntaxKind::AvailabilityVersionRestriction);
1637+
16351638
consumeToken();
16361639

16371640
llvm::VersionTuple Version;

stdlib/private/StdlibCollectionUnittest/CheckMutableCollectionType.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ self.test("\(testNamePrefix).partition/DispatchesThroughDirectStorageAccessors")
982982
withUnsafeMutableBufferPointerIsSupported ? 1 : 0,
983983
actualWUMBPIFNonNil + actualWCMSIAIFNonNil)
984984

985-
if #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) {
985+
if #available(SwiftStdlib 5.5, *) {
986986
// `partition(by:)` is expected to dispatch to the public API in releases
987987
// that contain https://github.com/apple/swift/pull/36003.
988988
expectEqual(0, actualWUMBPIF)

stdlib/private/StdlibUnittest/OpaqueIdentityFunctions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public func getUInt64(_ x: UInt64) -> UInt64 { return _opaqueIdentity(x) }
6666
public func getUInt(_ x: UInt) -> UInt { return _opaqueIdentity(x) }
6767

6868
#if !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64))
69-
@available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *)
69+
@available(SwiftStdlib 5.3, *)
7070
@inline(never)
7171
public func getFloat16(_ x: Float16) -> Float16 { return _opaqueIdentity(x) }
7272
#endif

stdlib/private/StdlibUnittest/StdlibCoreExtras.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ public func _isStdlibDebugConfiguration() -> Bool {
270270

271271
// Return true if the Swift runtime available is at least 5.1
272272
public func _hasSwift_5_1() -> Bool {
273-
if #available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) {
273+
if #available(SwiftStdlib 5.1, *) {
274274
return true
275275
}
276276
return false

stdlib/public/core/AnyHashable.swift

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,8 @@ 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(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) //SwiftStdlib 5.1
315+
else { return }
315316
_internalInvariant(condition(), message, file: file, line: line)
316317
#endif
317318
}

stdlib/public/core/BridgeObjectiveC.swift

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 15 additions & 15 deletions
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 { }

0 commit comments

Comments
 (0)