Skip to content

Commit a28c9d6

Browse files
authored
Merge pull request swiftlang#19143 from itaiferber/foundation-overlay-owned-annotations
Annotate Foundation overlay with __shared/__owned
2 parents c88d4e4 + 832317c commit a28c9d6

29 files changed

+127
-127
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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public struct Calendar : Hashable, Equatable, ReferenceConvertible, _MutableBoxi
9797
/// Returns a new Calendar.
9898
///
9999
/// - parameter identifier: The kind of calendar to use.
100-
public init(identifier: Identifier) {
100+
public init(identifier: __shared Identifier) {
101101
let result = __NSCalendarCreate(Calendar._toNSCalendarIdentifier(identifier))
102102
_handle = _MutableHandle(adoptingReference: result as! NSCalendar)
103103
_autoupdating = false
@@ -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: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -390,23 +390,23 @@ public struct CharacterSet : ReferenceConvertible, Equatable, Hashable, SetAlgeb
390390
/// Initialize with the characters in the given string.
391391
///
392392
/// - parameter string: The string content to inspect for characters.
393-
public init(charactersIn string: String) {
393+
public init(charactersIn string: __shared String) {
394394
_storage = _CharacterSetStorage(immutableReference: CFCharacterSetCreateWithCharactersInString(nil, string as CFString))
395395
}
396396

397397
/// Initialize with a bitmap representation.
398398
///
399399
/// This method is useful for creating a character set object with data from a file or other external data source.
400400
/// - parameter data: The bitmap representation.
401-
public init(bitmapRepresentation data: Data) {
401+
public init(bitmapRepresentation data: __shared Data) {
402402
_storage = _CharacterSetStorage(immutableReference: CFCharacterSetCreateWithBitmapRepresentation(nil, data as CFData))
403403
}
404404

405405
/// Initialize with the contents of a file.
406406
///
407407
/// Returns `nil` if there was an error reading the file.
408408
/// - parameter file: The file to read.
409-
public init?(contentsOfFile file: String) {
409+
public init?(contentsOfFile file: __shared String) {
410410
do {
411411
let data = try Data(contentsOf: URL(fileURLWithPath: file), options: .mappedIfSafe)
412412
_storage = _CharacterSetStorage(immutableReference: CFCharacterSetCreateWithBitmapRepresentation(nil, data as CFData))
@@ -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

@@ -427,7 +427,7 @@ public struct CharacterSet : ReferenceConvertible, Equatable, Hashable, SetAlgeb
427427
_storage = _uncopiedStorage
428428
}
429429

430-
fileprivate init(_builtIn: CFCharacterSetPredefinedSet) {
430+
fileprivate init(_builtIn: __shared CFCharacterSetPredefinedSet) {
431431
_storage = _CharacterSetStorage(immutableReference: CFCharacterSetGetPredefined(_builtIn))
432432
}
433433

stdlib/public/SDK/Foundation/Data.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
11781178
/// - parameter url: The `URL` to read.
11791179
/// - parameter options: Options for the read operation. Default value is `[]`.
11801180
/// - throws: An error in the Cocoa domain, if `url` cannot be read.
1181-
public init(contentsOf url: URL, options: Data.ReadingOptions = []) throws {
1181+
public init(contentsOf url: __shared URL, options: Data.ReadingOptions = []) throws {
11821182
let d = try NSData(contentsOf: url, options: ReadingOptions(rawValue: options.rawValue))
11831183
_backing = _DataStorage(immutableReference: d, offset: 0)
11841184
_sliceRange = 0..<d.length
@@ -1189,7 +1189,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
11891189
/// Returns nil when the input is not recognized as valid Base-64.
11901190
/// - parameter base64String: The string to parse.
11911191
/// - parameter options: Encoding options. Default value is `[]`.
1192-
public init?(base64Encoded base64String: String, options: Data.Base64DecodingOptions = []) {
1192+
public init?(base64Encoded base64String: __shared String, options: Data.Base64DecodingOptions = []) {
11931193
if let d = NSData(base64Encoded: base64String, options: Base64DecodingOptions(rawValue: options.rawValue)) {
11941194
_backing = _DataStorage(immutableReference: d, offset: 0)
11951195
_sliceRange = 0..<d.length
@@ -1204,7 +1204,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
12041204
///
12051205
/// - parameter base64Data: Base-64, UTF-8 encoded input data.
12061206
/// - parameter options: Decoding options. Default value is `[]`.
1207-
public init?(base64Encoded base64Data: Data, options: Data.Base64DecodingOptions = []) {
1207+
public init?(base64Encoded base64Data: __shared Data, options: Data.Base64DecodingOptions = []) {
12081208
if let d = NSData(base64Encoded: base64Data, options: Base64DecodingOptions(rawValue: options.rawValue)) {
12091209
_backing = _DataStorage(immutableReference: d, offset: 0)
12101210
_sliceRange = 0..<d.length
@@ -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/Decimal.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ extension Decimal {
452452
}
453453

454454
extension Decimal : CustomStringConvertible {
455-
public init?(string: String, locale: Locale? = nil) {
455+
public init?(string: __shared String, locale: __shared Locale? = nil) {
456456
let scan = Scanner(string: string)
457457
var theDecimal = Decimal()
458458
scan.locale = locale

stdlib/public/SDK/Foundation/IndexPath.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public struct IndexPath : ReferenceConvertible, Equatable, Hashable, MutableColl
156156
}
157157
}
158158

159-
mutating func append(contentsOf other: [Int]) {
159+
mutating func append(contentsOf other: __owned [Int]) {
160160
switch self {
161161
case .empty:
162162
switch other.count {
@@ -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

0 commit comments

Comments
 (0)