Skip to content

Commit a5ecf8c

Browse files
authored
Merge pull request #36702 from mikeash/concurrency-availability
[Concurrency] Add availability to Concurrency APIs.
2 parents 8bb3ab0 + 6d2fc9e commit a5ecf8c

File tree

75 files changed

+416
-24
lines changed

Some content is hidden

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

75 files changed

+416
-24
lines changed

include/swift/AST/ASTContext.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,10 @@ class ASTContext final {
738738
/// compiler for the target platform.
739739
AvailabilityContext getSwift54Availability();
740740

741+
/// Get the runtime availability of features introduced in the Swift 5.5
742+
/// compiler for the target platform.
743+
AvailabilityContext getSwift55Availability();
744+
741745
/// Get the runtime availability of features that have been introduced in the
742746
/// Swift compiler for future versions of the target platform.
743747
AvailabilityContext getSwiftFutureAvailability();

lib/AST/Availability.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ ASTContext::getIntermodulePrespecializedGenericMetadataAvailability() {
324324
}
325325

326326
AvailabilityContext ASTContext::getConcurrencyAvailability() {
327-
return getSwiftFutureAvailability();
327+
return getSwift55Availability();
328328
}
329329

330330
AvailabilityContext ASTContext::getDifferentiationAvailability() {
@@ -409,6 +409,11 @@ AvailabilityContext ASTContext::getSwift54Availability() {
409409
}
410410
}
411411

412+
AvailabilityContext ASTContext::getSwift55Availability() {
413+
return getSwiftFutureAvailability();
414+
}
415+
416+
412417
AvailabilityContext ASTContext::getSwiftFutureAvailability() {
413418
auto target = LangOpts.Target;
414419

stdlib/public/Concurrency/Actor.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,30 @@ import Swift
1717
///
1818
/// The \c Actor protocol generalizes over all actor types. Actor types
1919
/// implicitly conform to this protocol.
20+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
2021
public protocol Actor: AnyObject, Sendable {
2122
}
2223

2324
/// Called to initialize the default actor instance in an actor.
2425
/// The implementation will call this within the actor's initializer.
26+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
2527
@_silgen_name("swift_defaultActor_initialize")
2628
public func _defaultActorInitialize(_ actor: AnyObject)
2729

2830
/// Called to destroy the default actor instance in an actor.
2931
/// The implementation will call this within the actor's deinit.
32+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
3033
@_silgen_name("swift_defaultActor_destroy")
3134
public func _defaultActorDestroy(_ actor: AnyObject)
3235

3336
/// FIXME: only exists for the quick-and-dirty MainActor implementation.
37+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
3438
@_silgen_name("swift_MainActor_register")
3539
fileprivate func _registerMainActor(actor: AnyObject)
3640

3741
/// A singleton actor whose executor is equivalent to
3842
/// \c DispatchQueue.main, which is the main dispatch queue.
43+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
3944
@globalActor public actor MainActor {
4045
public static let shared = MainActor()
4146

@@ -44,6 +49,7 @@ fileprivate func _registerMainActor(actor: AnyObject)
4449
}
4550
}
4651

52+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
4753
extension MainActor {
4854
/// Execute the given body closure on the main actor.
4955
public static func run<T>(

stdlib/public/Concurrency/AsyncCompactMapSequence.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import Swift
1414

15+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
1516
extension AsyncSequence {
1617
@inlinable
1718
public __consuming func compactMap<ElementOfResult>(
@@ -21,6 +22,7 @@ extension AsyncSequence {
2122
}
2223
}
2324

25+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
2426
public struct AsyncCompactMapSequence<Base: AsyncSequence, ElementOfResult> {
2527
@usableFromInline
2628
let base: Base
@@ -38,6 +40,7 @@ public struct AsyncCompactMapSequence<Base: AsyncSequence, ElementOfResult> {
3840
}
3941
}
4042

43+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
4144
extension AsyncCompactMapSequence: AsyncSequence {
4245
public typealias Element = ElementOfResult
4346
public typealias AsyncIterator = Iterator

stdlib/public/Concurrency/AsyncDropFirstSequence.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import Swift
1414

15+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
1516
extension AsyncSequence {
1617
@inlinable
1718
public __consuming func dropFirst(
@@ -23,6 +24,7 @@ extension AsyncSequence {
2324
}
2425
}
2526

27+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
2628
public struct AsyncDropFirstSequence<Base: AsyncSequence> {
2729
@usableFromInline
2830
let base: Base
@@ -37,6 +39,7 @@ public struct AsyncDropFirstSequence<Base: AsyncSequence> {
3739
}
3840
}
3941

42+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
4043
extension AsyncDropFirstSequence: AsyncSequence {
4144
public typealias Element = Base.Element
4245
public typealias AsyncIterator = Iterator
@@ -75,6 +78,7 @@ extension AsyncDropFirstSequence: AsyncSequence {
7578
}
7679
}
7780

81+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
7882
extension AsyncDropFirstSequence {
7983
@inlinable
8084
public __consuming func dropFirst(

stdlib/public/Concurrency/AsyncDropWhileSequence.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import Swift
1414

15+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
1516
extension AsyncSequence {
1617
@inlinable
1718
public __consuming func drop(
@@ -21,6 +22,7 @@ extension AsyncSequence {
2122
}
2223
}
2324

25+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
2426
public struct AsyncDropWhileSequence<Base: AsyncSequence> {
2527
@usableFromInline
2628
let base: Base
@@ -38,6 +40,7 @@ public struct AsyncDropWhileSequence<Base: AsyncSequence> {
3840
}
3941
}
4042

43+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
4144
extension AsyncDropWhileSequence: AsyncSequence {
4245
public typealias Element = Base.Element
4346
public typealias AsyncIterator = Iterator

stdlib/public/Concurrency/AsyncFilterSequence.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import Swift
1414

15+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
1516
extension AsyncSequence {
1617
@inlinable
1718
public __consuming func filter(
@@ -21,6 +22,7 @@ extension AsyncSequence {
2122
}
2223
}
2324

25+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
2426
public struct AsyncFilterSequence<Base: AsyncSequence> {
2527
@usableFromInline
2628
let base: Base
@@ -38,6 +40,7 @@ public struct AsyncFilterSequence<Base: AsyncSequence> {
3840
}
3941
}
4042

43+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
4144
extension AsyncFilterSequence: AsyncSequence {
4245
public typealias Element = Base.Element
4346
public typealias AsyncIterator = Iterator

stdlib/public/Concurrency/AsyncFlatMapSequence.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import Swift
1414

15+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
1516
extension AsyncSequence {
1617
@inlinable
1718
public __consuming func flatMap<SegmentOfResult: AsyncSequence>(
@@ -21,6 +22,7 @@ extension AsyncSequence {
2122
}
2223
}
2324

25+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
2426
public struct AsyncFlatMapSequence<Base: AsyncSequence, SegmentOfResult: AsyncSequence> {
2527
@usableFromInline
2628
let base: Base
@@ -38,6 +40,7 @@ public struct AsyncFlatMapSequence<Base: AsyncSequence, SegmentOfResult: AsyncSe
3840
}
3941
}
4042

43+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
4144
extension AsyncFlatMapSequence: AsyncSequence {
4245
public typealias Element = SegmentOfResult.Element
4346
public typealias AsyncIterator = Iterator

stdlib/public/Concurrency/AsyncIteratorProtocol.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import Swift
1414

15+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
1516
@rethrows
1617
public protocol AsyncIteratorProtocol {
1718
associatedtype Element

stdlib/public/Concurrency/AsyncMapSequence.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import Swift
1414

15+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
1516
extension AsyncSequence {
1617
@inlinable
1718
public __consuming func map<Transformed>(
@@ -21,6 +22,7 @@ extension AsyncSequence {
2122
}
2223
}
2324

25+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
2426
public struct AsyncMapSequence<Base: AsyncSequence, Transformed> {
2527
@usableFromInline
2628
let base: Base
@@ -38,6 +40,7 @@ public struct AsyncMapSequence<Base: AsyncSequence, Transformed> {
3840
}
3941
}
4042

43+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
4144
extension AsyncMapSequence: AsyncSequence {
4245
public typealias Element = Transformed
4346
public typealias AsyncIterator = Iterator

stdlib/public/Concurrency/AsyncPrefixSequence.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import Swift
1414

15+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
1516
extension AsyncSequence {
1617
@inlinable
1718
public __consuming func prefix(
@@ -23,6 +24,7 @@ extension AsyncSequence {
2324
}
2425
}
2526

27+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
2628
public struct AsyncPrefixSequence<Base: AsyncSequence> {
2729
@usableFromInline
2830
let base: Base
@@ -37,6 +39,7 @@ public struct AsyncPrefixSequence<Base: AsyncSequence> {
3739
}
3840
}
3941

42+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
4043
extension AsyncPrefixSequence: AsyncSequence {
4144
public typealias Element = Base.Element
4245
public typealias AsyncIterator = Iterator

stdlib/public/Concurrency/AsyncPrefixWhileSequence.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import Swift
1414

15+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
1516
extension AsyncSequence {
1617
@inlinable
1718
public __consuming func prefix(
@@ -21,6 +22,7 @@ extension AsyncSequence {
2122
}
2223
}
2324

25+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
2426
public struct AsyncPrefixWhileSequence<Base: AsyncSequence> {
2527
@usableFromInline
2628
let base: Base
@@ -38,6 +40,7 @@ public struct AsyncPrefixWhileSequence<Base: AsyncSequence> {
3840
}
3941
}
4042

43+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
4144
extension AsyncPrefixWhileSequence: AsyncSequence {
4245
public typealias Element = Base.Element
4346
public typealias AsyncIterator = Iterator

stdlib/public/Concurrency/AsyncSequence.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@
1212

1313
import Swift
1414

15+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
1516
@rethrows
1617
public protocol AsyncSequence {
1718
associatedtype AsyncIterator: AsyncIteratorProtocol where AsyncIterator.Element == Element
1819
associatedtype Element
1920
__consuming func makeAsyncIterator() -> AsyncIterator
2021
}
2122

23+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
2224
extension AsyncSequence {
2325
@inlinable
2426
public func reduce<Result>(
@@ -49,6 +51,7 @@ extension AsyncSequence {
4951
}
5052
}
5153

54+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
5255
@inlinable
5356
@inline(__always)
5457
func _contains<Source: AsyncSequence>(
@@ -63,6 +66,7 @@ func _contains<Source: AsyncSequence>(
6366
return false
6467
}
6568

69+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
6670
extension AsyncSequence {
6771
@inlinable
6872
public func contains(
@@ -79,6 +83,7 @@ extension AsyncSequence {
7983
}
8084
}
8185

86+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
8287
extension AsyncSequence where Element: Equatable {
8388
@inlinable
8489
public func contains(_ search: Element) async rethrows -> Bool {
@@ -91,6 +96,7 @@ extension AsyncSequence where Element: Equatable {
9196
}
9297
}
9398

99+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
94100
@inlinable
95101
@inline(__always)
96102
func _first<Source: AsyncSequence>(
@@ -105,6 +111,7 @@ func _first<Source: AsyncSequence>(
105111
return nil
106112
}
107113

114+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
108115
extension AsyncSequence {
109116
@inlinable
110117
public func first(
@@ -114,6 +121,7 @@ extension AsyncSequence {
114121
}
115122
}
116123

124+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
117125
extension AsyncSequence {
118126
@inlinable
119127
@warn_unqualified_access
@@ -150,6 +158,7 @@ extension AsyncSequence {
150158
}
151159
}
152160

161+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
153162
extension AsyncSequence where Element: Comparable {
154163
@inlinable
155164
@warn_unqualified_access

stdlib/public/Concurrency/AsyncThrowingCompactMapSequence.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import Swift
1414

15+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
1516
extension AsyncSequence {
1617
@inlinable
1718
public __consuming func compactMap<ElementOfResult>(
@@ -21,6 +22,7 @@ extension AsyncSequence {
2122
}
2223
}
2324

25+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
2426
public struct AsyncThrowingCompactMapSequence<Base: AsyncSequence, ElementOfResult> {
2527
@usableFromInline
2628
let base: Base
@@ -38,6 +40,7 @@ public struct AsyncThrowingCompactMapSequence<Base: AsyncSequence, ElementOfResu
3840
}
3941
}
4042

43+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
4144
extension AsyncThrowingCompactMapSequence: AsyncSequence {
4245
public typealias Element = ElementOfResult
4346
public typealias AsyncIterator = Iterator

stdlib/public/Concurrency/AsyncThrowingDropWhileSequence.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import Swift
1414

15+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
1516
extension AsyncSequence {
1617
@inlinable
1718
public __consuming func drop(
@@ -21,6 +22,7 @@ extension AsyncSequence {
2122
}
2223
}
2324

25+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
2426
public struct AsyncThrowingDropWhileSequence<Base: AsyncSequence> {
2527
@usableFromInline
2628
let base: Base
@@ -38,6 +40,7 @@ public struct AsyncThrowingDropWhileSequence<Base: AsyncSequence> {
3840
}
3941
}
4042

43+
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
4144
extension AsyncThrowingDropWhileSequence: AsyncSequence {
4245
public typealias Element = Base.Element
4346
public typealias AsyncIterator = Iterator

0 commit comments

Comments
 (0)