Skip to content

Commit 402457b

Browse files
author
Itai Ferber
committed
Annotate Foundation overlay with __shared/__owned
1 parent e3f3e93 commit 402457b

22 files changed

+76
-76
lines changed

stdlib/public/SDK/Foundation/AffineTransform.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public struct AffineTransform : ReferenceConvertible, Hashable, CustomStringConv
3333
self.tY = tY
3434
}
3535

36-
fileprivate init(reference: NSAffineTransform) {
36+
fileprivate init(reference: __shared NSAffineTransform) {
3737
m11 = reference.transformStruct.m11
3838
m12 = reference.transformStruct.m12
3939
m21 = reference.transformStruct.m21

stdlib/public/SDK/Foundation/Boxing.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ internal final class _MutableHandle<MutableType : NSObject>
1919
where MutableType : NSCopying {
2020
fileprivate var _pointer : MutableType
2121

22-
init(reference : MutableType) {
22+
init(reference : __shared MutableType) {
2323
_pointer = reference.copy() as! MutableType
2424
}
2525

stdlib/public/SDK/Foundation/Calendar.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public struct Calendar : Hashable, Equatable, ReferenceConvertible, _MutableBoxi
106106
// MARK: -
107107
// MARK: Bridging
108108

109-
fileprivate init(reference : NSCalendar) {
109+
fileprivate init(reference : __shared NSCalendar) {
110110
_handle = _MutableHandle(reference: reference)
111111
if __NSCalendarIsAutoupdating(reference) {
112112
_autoupdating = true

stdlib/public/SDK/Foundation/CharacterSet.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ public struct CharacterSet : ReferenceConvertible, Equatable, Hashable, SetAlgeb
415415
}
416416
}
417417

418-
fileprivate init(_bridged characterSet: NSCharacterSet) {
418+
fileprivate init(_bridged characterSet: __shared NSCharacterSet) {
419419
_storage = _CharacterSetStorage(immutableReference: characterSet.copy() as! CFCharacterSet)
420420
}
421421

stdlib/public/SDK/Foundation/Data.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1220,7 +1220,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
12201220
/// If the resulting value is mutated, then `Data` will invoke the `mutableCopy()` function on the reference to copy the contents. You may customize the behavior of that function if you wish to return a specialized mutable subclass.
12211221
///
12221222
/// - parameter reference: The instance of `NSData` that you wish to wrap. This instance will be copied by `struct Data`.
1223-
public init(referencing reference: NSData) {
1223+
public init(referencing reference: __shared NSData) {
12241224
#if DEPLOYMENT_RUNTIME_SWIFT
12251225
let providesConcreteBacking = reference._providesConcreteBacking()
12261226
#else

stdlib/public/SDK/Foundation/DateComponents.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ public struct DateComponents : ReferenceConvertible, Hashable, Equatable, _Mutab
269269

270270
// MARK: - Bridging Helpers
271271

272-
fileprivate init(reference: NSDateComponents) {
272+
fileprivate init(reference: __shared NSDateComponents) {
273273
_handle = _MutableHandle(reference: reference)
274274
}
275275

stdlib/public/SDK/Foundation/IndexPath.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ public struct IndexPath : ReferenceConvertible, Equatable, Hashable, MutableColl
684684

685685
// MARK: - Bridging Helpers
686686

687-
fileprivate init(nsIndexPath: ReferenceType) {
687+
fileprivate init(nsIndexPath: __shared ReferenceType) {
688688
let count = nsIndexPath.length
689689
if count == 0 {
690690
_indexes = []

stdlib/public/SDK/Foundation/IndexSet.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ public struct IndexSet : ReferenceConvertible, Equatable, BidirectionalCollectio
661661
return _handle.reference
662662
}
663663

664-
fileprivate init(reference: NSIndexSet) {
664+
fileprivate init(reference: __shared NSIndexSet) {
665665
_handle = _MutablePairHandle(reference)
666666
}
667667
}

stdlib/public/SDK/Foundation/JSONEncoder.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ fileprivate struct _JSONEncodingStorage {
387387
return array
388388
}
389389

390-
fileprivate mutating func push(container: NSObject) {
390+
fileprivate mutating func push(container: __owned NSObject) {
391391
self.containers.append(container)
392392
}
393393

@@ -961,7 +961,7 @@ fileprivate class _JSONReferencingEncoder : _JSONEncoder {
961961

962962
/// Initializes `self` by referencing the given dictionary container in the given encoder.
963963
fileprivate init(referencing encoder: _JSONEncoder,
964-
key: CodingKey, convertedKey: CodingKey, wrapping dictionary: NSMutableDictionary) {
964+
key: CodingKey, convertedKey: __shared CodingKey, wrapping dictionary: NSMutableDictionary) {
965965
self.encoder = encoder
966966
self.reference = .dictionary(dictionary, convertedKey.stringValue)
967967
super.init(options: encoder.options, codingPath: encoder.codingPath)
@@ -1273,7 +1273,7 @@ fileprivate struct _JSONDecodingStorage {
12731273
return self.containers.last!
12741274
}
12751275

1276-
fileprivate mutating func push(container: Any) {
1276+
fileprivate mutating func push(container: __owned Any) {
12771277
self.containers.append(container)
12781278
}
12791279

@@ -1616,7 +1616,7 @@ fileprivate struct _JSONKeyedDecodingContainer<K : CodingKey> : KeyedDecodingCon
16161616
return _JSONUnkeyedDecodingContainer(referencing: self.decoder, wrapping: array)
16171617
}
16181618

1619-
private func _superDecoder(forKey key: CodingKey) throws -> Decoder {
1619+
private func _superDecoder(forKey key: __owned CodingKey) throws -> Decoder {
16201620
self.decoder.codingPath.append(key)
16211621
defer { self.decoder.codingPath.removeLast() }
16221622

stdlib/public/SDK/Foundation/Locale.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public struct Locale : Hashable, Equatable, ReferenceConvertible {
5252
_autoupdating = false
5353
}
5454

55-
fileprivate init(reference: NSLocale) {
55+
fileprivate init(reference: __shared NSLocale) {
5656
_wrapped = reference.copy() as! NSLocale
5757
if __NSLocaleIsAutoupdating(reference) {
5858
_autoupdating = true

stdlib/public/SDK/Foundation/NSArray.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ extension Array : _ObjectiveCBridgeable {
3030
///
3131
/// The provided `NSArray` will be copied to ensure that the copy can
3232
/// not be mutated by other code.
33-
internal init(_cocoaArray: NSArray) {
33+
internal init(_cocoaArray: __shared NSArray) {
3434
assert(_isBridgedVerbatimToObjectiveC(Element.self),
3535
"Array can be backed by NSArray only when the element type can be bridged verbatim to Objective-C")
3636
// FIXME: We would like to call CFArrayCreateCopy() to avoid doing an
@@ -153,7 +153,7 @@ extension NSArray {
153153
/// Discussion: After an immutable array has been initialized in
154154
/// this way, it cannot be modified.
155155
@nonobjc
156-
public convenience init(array anArray: NSArray) {
156+
public convenience init(array anArray: __shared NSArray) {
157157
self.init(array: anArray as Array)
158158
}
159159
}

stdlib/public/SDK/Foundation/NSDictionary.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ extension Dictionary {
3434
///
3535
/// The provided `NSDictionary` will be copied to ensure that the copy can
3636
/// not be mutated by other code.
37-
public init(_cocoaDictionary: _NSDictionary) {
37+
public init(_cocoaDictionary: __shared _NSDictionary) {
3838
assert(
3939
_isBridgedVerbatimToObjectiveC(Key.self) &&
4040
_isBridgedVerbatimToObjectiveC(Value.self),
@@ -165,7 +165,7 @@ extension NSDictionary : Sequence {
165165
return nil
166166
}
167167

168-
internal init(_ _dict: NSDictionary) {
168+
internal init(_ _dict: __shared NSDictionary) {
169169
_fastIterator = NSFastEnumerationIterator(_dict)
170170
}
171171
}
@@ -219,7 +219,7 @@ extension NSDictionary {
219219
/// than the original receiver--containing the keys and values
220220
/// found in `otherDictionary`.
221221
@objc(_swiftInitWithDictionary_NSDictionary:)
222-
public convenience init(dictionary otherDictionary: NSDictionary) {
222+
public convenience init(dictionary otherDictionary: __shared NSDictionary) {
223223
// FIXME(performance)(compiler limitation): we actually want to do just
224224
// `self = otherDictionary.copy()`, but Swift does not have factory
225225
// initializers right now.

stdlib/public/SDK/Foundation/NSError.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ extension _BridgedNSError {
398398
extension _BridgedNSError where Self.RawValue: FixedWidthInteger {
399399
public var _code: Int { return Int(rawValue) }
400400

401-
public init?(_bridgedNSError: NSError) {
401+
public init?(_bridgedNSError: __shared NSError) {
402402
if _bridgedNSError.domain != Self._nsErrorDomain {
403403
return nil
404404
}

0 commit comments

Comments
 (0)