Skip to content

Commit f9f640b

Browse files
committed
Sendablize the standard library
oops dont add this flag no more nonisolated
1 parent 92f5eee commit f9f640b

Some content is hidden

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

44 files changed

+333
-11
lines changed

stdlib/public/core/Algorithm.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ public struct EnumeratedSequence<Base: Sequence> {
103103
}
104104
}
105105

106+
extension EnumeratedSequence: Sendable where Base: Sendable {}
107+
106108
extension EnumeratedSequence {
107109
/// The iterator for `EnumeratedSequence`.
108110
///
@@ -134,6 +136,8 @@ extension EnumeratedSequence {
134136
}
135137
}
136138

139+
extension EnumeratedSequence.Iterator: Sendable where Base.Iterator: Sendable {}
140+
137141
extension EnumeratedSequence.Iterator: IteratorProtocol, Sequence {
138142
/// The type of element returned by `next()`.
139143
public typealias Element = (offset: Int, element: Base.Element)

stdlib/public/core/AnyHashable.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,9 @@ public struct AnyHashable {
212212
}
213213
}
214214

215+
@available(*, unavailable)
216+
extension AnyHashable: Sendable {}
217+
215218
@_unavailableInEmbedded
216219
extension AnyHashable: Equatable {
217220
/// Returns a Boolean value indicating whether two type-erased hashable

stdlib/public/core/AtomicInt.swift.gyb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ public final class _stdlib_AtomicInt {
6060
}
6161
}
6262

63+
@available(*, unavailable)
64+
extension _stdlib_AtomicInt: Sendable {}
65+
6366
@usableFromInline // used by SwiftPrivate._stdlib_AtomicInt
6467
internal func _swift_stdlib_atomicCompareExchangeStrongInt(
6568
object target: UnsafeMutablePointer<Int>,

stdlib/public/core/Bitset.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ internal struct _UnsafeBitset {
3333
}
3434
}
3535

36+
@available(*, unavailable)
37+
extension _UnsafeBitset: Sendable {}
38+
3639
extension _UnsafeBitset {
3740
@inlinable
3841
@inline(__always)
@@ -179,6 +182,9 @@ extension _UnsafeBitset: Sequence {
179182
}
180183
}
181184

185+
@available(*, unavailable)
186+
extension _UnsafeBitset.Iterator: Sendable {}
187+
182188
////////////////////////////////////////////////////////////////////////////////
183189

184190
extension _UnsafeBitset {

stdlib/public/core/BridgeObjectiveC.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ public struct _BridgeableMetatype: _ObjectiveCBridgeable {
182182
}
183183
}
184184

185+
extension _BridgeableMetatype: Sendable {}
185186

186187
//===--- Bridging facilities written in Objective-C -----------------------===//
187188
// Functions that must discover and possibly use an arbitrary type's

stdlib/public/core/CocoaArray.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,8 @@ internal struct _CocoaArrayWrapper: RandomAccessCollection {
160160
return (IndexingIterator(_elements: self, _position: c), c)
161161
}
162162
}
163+
164+
@available(*, unavailable)
165+
extension _CocoaArrayWrapper: Sendable {}
166+
163167
#endif

stdlib/public/core/Codable.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,9 @@ public struct KeyedEncodingContainer<K: CodingKey> :
933933
}
934934
}
935935

936+
@available(*, unavailable)
937+
extension KeyedEncodingContainer: Sendable {}
938+
936939
/// A type that provides a view into a decoder's storage and is used to hold
937940
/// the encoded properties of a decodable type in a keyed manner.
938941
///
@@ -2115,6 +2118,9 @@ public struct KeyedDecodingContainer<K: CodingKey> :
21152118
}
21162119
}
21172120

2121+
@available(*, unavailable)
2122+
extension KeyedDecodingContainer: Sendable {}
2123+
21182124
//===----------------------------------------------------------------------===//
21192125
// Unkeyed Encoding Containers
21202126
//===----------------------------------------------------------------------===//

stdlib/public/core/ContiguousArrayBuffer.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ internal final class __EmptyArrayStorage
6363
}
6464
}
6565

66+
@available(*, unavailable)
67+
extension __EmptyArrayStorage: Sendable {}
68+
6669
#if $Embedded
6770
// In embedded Swift, the stdlib is a .swiftmodule only without any .o/.a files,
6871
// to allow consuming it by clients with different LLVM codegen setting (-mcpu
@@ -117,6 +120,9 @@ internal final class __StaticArrayStorage
117120
}
118121
}
119122

123+
@available(*, unavailable)
124+
extension __StaticArrayStorage: Sendable {}
125+
120126
/// The empty array prototype. We use the same object for all empty
121127
/// `[Native]Array<Element>`s.
122128
@inlinable
@@ -306,6 +312,9 @@ internal final class _ContiguousArrayStorage<
306312
}
307313
}
308314

315+
@available(*, unavailable)
316+
extension _ContiguousArrayStorage: Sendable {}
317+
309318
@_alwaysEmitIntoClient
310319
@inline(__always)
311320
internal func _uncheckedUnsafeBitCast<T, U>(_ x: T, to type: U.Type) -> U {
@@ -968,6 +977,9 @@ internal struct _ContiguousArrayBuffer<Element>: _ArrayBufferProtocol {
968977
}
969978
}
970979

980+
@available(*, unavailable)
981+
extension _ContiguousArrayBuffer: Sendable {}
982+
971983
/// Append the elements of `rhs` to `lhs`.
972984
@inlinable
973985
internal func += <Element, C: Collection>(
@@ -1218,3 +1230,6 @@ internal struct _UnsafePartiallyInitializedContiguousArrayBuffer<Element> {
12181230
return ContiguousArray(_buffer: finalResult)
12191231
}
12201232
}
1233+
1234+
@available(*, unavailable)
1235+
extension _UnsafePartiallyInitializedContiguousArrayBuffer: Sendable {}

stdlib/public/core/Dictionary.swift

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1789,6 +1789,8 @@ extension Dictionary {
17891789
}
17901790
}
17911791

1792+
extension Dictionary.Index._Variant: @unchecked Sendable {}
1793+
17921794
extension Dictionary.Index {
17931795
#if _runtime(_ObjC)
17941796
@usableFromInline @_transparent
@@ -1967,6 +1969,9 @@ extension Dictionary {
19671969
}
19681970
}
19691971

1972+
extension Dictionary.Iterator._Variant: @unchecked Sendable
1973+
where Key: Sendable, Value: Sendable {}
1974+
19701975
extension Dictionary.Iterator {
19711976
#if _runtime(_ObjC)
19721977
@usableFromInline @_transparent
@@ -2119,16 +2124,16 @@ public typealias DictionaryIterator<Key: Hashable, Value> =
21192124
Dictionary<Key, Value>.Iterator
21202125

21212126
extension Dictionary: @unchecked Sendable
2122-
where Key: Sendable, Value: Sendable { }
2127+
where Key: Sendable, Value: Sendable {}
21232128
extension Dictionary.Keys: @unchecked Sendable
2124-
where Key: Sendable, Value: Sendable { }
2129+
where Key: Sendable, Value: Sendable {}
21252130
extension Dictionary.Values: @unchecked Sendable
2126-
where Key: Sendable, Value: Sendable { }
2131+
where Key: Sendable, Value: Sendable {}
21272132
extension Dictionary.Keys.Iterator: @unchecked Sendable
2128-
where Key: Sendable, Value: Sendable { }
2133+
where Key: Sendable, Value: Sendable {}
21292134
extension Dictionary.Values.Iterator: @unchecked Sendable
2130-
where Key: Sendable, Value: Sendable { }
2135+
where Key: Sendable, Value: Sendable {}
21312136
extension Dictionary.Index: @unchecked Sendable
2132-
where Key: Sendable, Value: Sendable { }
2137+
where Key: Sendable, Value: Sendable {}
21332138
extension Dictionary.Iterator: @unchecked Sendable
2134-
where Key: Sendable, Value: Sendable { }
2139+
where Key: Sendable, Value: Sendable {}

stdlib/public/core/DictionaryBridging.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,9 @@ final internal class _SwiftDeferredNSDictionary<Key: Hashable, Value>
421421
}
422422
}
423423

424+
@available(*, unavailable)
425+
extension _SwiftDeferredNSDictionary: Sendable {}
426+
424427
// NOTE: older runtimes called this struct _CocoaDictionary. The two
425428
// must coexist without conflicting ObjC class names from the nested
426429
// classes, so it was renamed. The old names must not be used in the new
@@ -437,6 +440,9 @@ internal struct __CocoaDictionary {
437440
}
438441
}
439442

443+
@available(*, unavailable)
444+
extension __CocoaDictionary: Sendable {}
445+
440446
extension __CocoaDictionary {
441447
@usableFromInline
442448
internal func isEqual(to other: __CocoaDictionary) -> Bool {
@@ -733,6 +739,9 @@ extension __CocoaDictionary: Sequence {
733739
}
734740
}
735741

742+
@available(*, unavailable)
743+
extension __CocoaDictionary.Iterator: Sendable {}
744+
736745
extension __CocoaDictionary.Iterator: IteratorProtocol {
737746
@usableFromInline
738747
internal typealias Element = (key: AnyObject, value: AnyObject)

0 commit comments

Comments
 (0)