Skip to content

Commit 9f042bc

Browse files
author
Itai Ferber
committed
Apply annotations to further non-trivial types
1 parent 402457b commit 9f042bc

15 files changed

+51
-51
lines changed

stdlib/public/SDK/Foundation/Calendar.swift

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

stdlib/public/SDK/Foundation/CharacterSet.swift

Lines changed: 4 additions & 4 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))
@@ -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: 3 additions & 3 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: __shared 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: __shared 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: __shared 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

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

stdlib/public/SDK/Foundation/NSError.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ extension CFError : Error {
359359
public protocol _ObjectiveCBridgeableError : Error {
360360
/// Produce a value of the error type corresponding to the given NSError,
361361
/// or return nil if it cannot be bridged.
362-
init?(_bridgedNSError: NSError)
362+
init?(_bridgedNSError: __shared NSError)
363363
}
364364

365365
/// A hook for the runtime to use _ObjectiveCBridgeableError in order to

stdlib/public/SDK/Foundation/NSExpression.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
extension NSExpression {
1616
// + (NSExpression *) expressionWithFormat:(NSString *)expressionFormat, ...;
1717
public
18-
convenience init(format expressionFormat: String, _ args: CVarArg...) {
18+
convenience init(format expressionFormat: __shared String, _ args: CVarArg...) {
1919
let va_args = getVaList(args)
2020
self.init(format: expressionFormat, arguments: va_args)
2121
}

stdlib/public/SDK/Foundation/NSObject.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ fileprivate extension NSObject {
8181

8282
@nonobjc static var keyPathTableLock = NSLock()
8383

84-
@nonobjc fileprivate static func _bridgeKeyPath(_ keyPath:AnyKeyPath) -> String {
84+
@nonobjc fileprivate static func _bridgeKeyPath(_ keyPath: __owned AnyKeyPath) -> String {
8585
guard let keyPathString = keyPath._kvcKeyPathString else { fatalError("Could not extract a String from KeyPath \(keyPath)") }
8686
_KVOKeyPathBridgeMachinery.keyPathTableLock.lock()
8787
defer { _KVOKeyPathBridgeMachinery.keyPathTableLock.unlock() }
@@ -199,27 +199,27 @@ public extension _KeyValueCodingAndObserving {
199199
return result
200200
}
201201

202-
public func willChangeValue<Value>(for keyPath: KeyPath<Self, Value>) {
202+
public func willChangeValue<Value>(for keyPath: __owned KeyPath<Self, Value>) {
203203
(self as! NSObject).willChangeValue(forKey: _bridgeKeyPathToString(keyPath))
204204
}
205205

206-
public func willChange<Value>(_ changeKind: NSKeyValueChange, valuesAt indexes: IndexSet, for keyPath: KeyPath<Self, Value>) {
206+
public func willChange<Value>(_ changeKind: NSKeyValueChange, valuesAt indexes: IndexSet, for keyPath: __owned KeyPath<Self, Value>) {
207207
(self as! NSObject).willChange(changeKind, valuesAt: indexes, forKey: _bridgeKeyPathToString(keyPath))
208208
}
209209

210-
public func willChangeValue<Value>(for keyPath: KeyPath<Self, Value>, withSetMutation mutation: NSKeyValueSetMutationKind, using set: Set<Value>) -> Void {
210+
public func willChangeValue<Value>(for keyPath: __owned KeyPath<Self, Value>, withSetMutation mutation: NSKeyValueSetMutationKind, using set: Set<Value>) -> Void {
211211
(self as! NSObject).willChangeValue(forKey: _bridgeKeyPathToString(keyPath), withSetMutation: mutation, using: set)
212212
}
213213

214-
public func didChangeValue<Value>(for keyPath: KeyPath<Self, Value>) {
214+
public func didChangeValue<Value>(for keyPath: __owned KeyPath<Self, Value>) {
215215
(self as! NSObject).didChangeValue(forKey: _bridgeKeyPathToString(keyPath))
216216
}
217217

218-
public func didChange<Value>(_ changeKind: NSKeyValueChange, valuesAt indexes: IndexSet, for keyPath: KeyPath<Self, Value>) {
218+
public func didChange<Value>(_ changeKind: NSKeyValueChange, valuesAt indexes: IndexSet, for keyPath: __owned KeyPath<Self, Value>) {
219219
(self as! NSObject).didChange(changeKind, valuesAt: indexes, forKey: _bridgeKeyPathToString(keyPath))
220220
}
221221

222-
public func didChangeValue<Value>(for keyPath: KeyPath<Self, Value>, withSetMutation mutation: NSKeyValueSetMutationKind, using set: Set<Value>) -> Void {
222+
public func didChangeValue<Value>(for keyPath: __owned KeyPath<Self, Value>, withSetMutation mutation: NSKeyValueSetMutationKind, using set: Set<Value>) -> Void {
223223
(self as! NSObject).didChangeValue(forKey: _bridgeKeyPathToString(keyPath), withSetMutation: mutation, using: set)
224224
}
225225
}

stdlib/public/SDK/Foundation/NSPredicate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
extension NSPredicate {
1616
// + (NSPredicate *)predicateWithFormat:(NSString *)predicateFormat, ...;
1717
public
18-
convenience init(format predicateFormat: String, _ args: CVarArg...) {
18+
convenience init(format predicateFormat: __shared String, _ args: CVarArg...) {
1919
let va_args = getVaList(args)
2020
self.init(format: predicateFormat, arguments: va_args)
2121
}

stdlib/public/SDK/Foundation/NSRange.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ extension NSRange : CustomStringConvertible, CustomDebugStringConvertible {
3737
}
3838

3939
extension NSRange {
40-
public init?(_ string: String) {
40+
public init?(_ string: __shared String) {
4141
var savedLocation = 0
4242
if string.isEmpty {
4343
// fail early if the string is empty
@@ -178,7 +178,7 @@ extension Range where Bound == Int {
178178
}
179179

180180
extension Range where Bound == String.Index {
181-
public init?(_ range: NSRange, in string: String) {
181+
public init?(_ range: NSRange, in string: __shared String) {
182182
let u = string.utf16
183183
guard range.location != NSNotFound,
184184
let start = u.index(u.startIndex, offsetBy: range.location, limitedBy: u.endIndex),

stdlib/public/SDK/Foundation/NSStringAPI.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ extension String {
187187
/// - Parameters:
188188
/// - bytes: A sequence of bytes to interpret using `encoding`.
189189
/// - encoding: The ecoding to use to interpret `bytes`.
190-
public init? <S: Sequence>(bytes: S, encoding: Encoding)
190+
public init? <S: Sequence>(bytes: __shared S, encoding: Encoding)
191191
where S.Iterator.Element == UInt8 {
192192
let byteArray = Array(bytes)
193193
if let ns = NSString(
@@ -267,7 +267,7 @@ extension String {
267267
/// Produces a string created by reading data from the file at a
268268
/// given path interpreted using a given encoding.
269269
public init(
270-
contentsOfFile path: String,
270+
contentsOfFile path: __shared String,
271271
encoding enc: Encoding
272272
) throws {
273273
let ns = try NSString(contentsOfFile: path, encoding: enc.rawValue)
@@ -283,7 +283,7 @@ extension String {
283283
/// a given path and returns by reference the encoding used to
284284
/// interpret the file.
285285
public init(
286-
contentsOfFile path: String,
286+
contentsOfFile path: __shared String,
287287
usedEncoding: inout Encoding
288288
) throws {
289289
var enc: UInt = 0
@@ -293,7 +293,7 @@ extension String {
293293
}
294294

295295
public init(
296-
contentsOfFile path: String
296+
contentsOfFile path: __shared String
297297
) throws {
298298
let ns = try NSString(contentsOfFile: path, usedEncoding: nil)
299299
self = String._unconditionallyBridgeFromObjectiveC(ns)
@@ -308,7 +308,7 @@ extension String {
308308
/// interpreted using a given encoding. Errors are written into the
309309
/// inout `error` argument.
310310
public init(
311-
contentsOf url: URL,
311+
contentsOf url: __shared URL,
312312
encoding enc: Encoding
313313
) throws {
314314
let ns = try NSString(contentsOf: url, encoding: enc.rawValue)
@@ -324,7 +324,7 @@ extension String {
324324
/// and returns by reference the encoding used to interpret the
325325
/// data. Errors are written into the inout `error` argument.
326326
public init(
327-
contentsOf url: URL,
327+
contentsOf url: __shared URL,
328328
usedEncoding: inout Encoding
329329
) throws {
330330
var enc: UInt = 0
@@ -334,7 +334,7 @@ extension String {
334334
}
335335

336336
public init(
337-
contentsOf url: URL
337+
contentsOf url: __shared URL
338338
) throws {
339339
let ns = try NSString(contentsOf: url, usedEncoding: nil)
340340
self = String._unconditionallyBridgeFromObjectiveC(ns)
@@ -365,7 +365,7 @@ extension String {
365365

366366
/// Returns a `String` initialized by converting given `data` into
367367
/// Unicode characters using a given `encoding`.
368-
public init?(data: Data, encoding: Encoding) {
368+
public init?(data: __shared Data, encoding: Encoding) {
369369
guard let s = NSString(data: data, encoding: encoding.rawValue) else { return nil }
370370
self = String._unconditionallyBridgeFromObjectiveC(s)
371371
}
@@ -375,7 +375,7 @@ extension String {
375375
/// Returns a `String` object initialized by using a given
376376
/// format string as a template into which the remaining argument
377377
/// values are substituted.
378-
public init(format: String, _ arguments: CVarArg...) {
378+
public init(format: __shared String, _ arguments: CVarArg...) {
379379
self = String(format: format, arguments: arguments)
380380
}
381381

@@ -386,7 +386,7 @@ extension String {
386386
/// Returns a `String` object initialized by using a given
387387
/// format string as a template into which the remaining argument
388388
/// values are substituted according to the user's default locale.
389-
public init(format: String, arguments: [CVarArg]) {
389+
public init(format: __shared String, arguments: __shared [CVarArg]) {
390390
self = String(format: format, locale: nil, arguments: arguments)
391391
}
392392

@@ -395,7 +395,7 @@ extension String {
395395
/// Returns a `String` object initialized by using a given
396396
/// format string as a template into which the remaining argument
397397
/// values are substituted according to given locale information.
398-
public init(format: String, locale: Locale?, _ args: CVarArg...) {
398+
public init(format: __shared String, locale: __shared Locale?, _ args: CVarArg...) {
399399
self = String(format: format, locale: locale, arguments: args)
400400
}
401401

@@ -407,7 +407,7 @@ extension String {
407407
/// Returns a `String` object initialized by using a given
408408
/// format string as a template into which the remaining argument
409409
/// values are substituted according to given locale information.
410-
public init(format: String, locale: Locale?, arguments: [CVarArg]) {
410+
public init(format: __shared String, locale: __shared Locale?, arguments: __shared [CVarArg]) {
411411
#if DEPLOYMENT_RUNTIME_SWIFT
412412
self = withVaList(arguments) {
413413
String._unconditionallyBridgeFromObjectiveC(

stdlib/public/SDK/Foundation/TimeZone.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public struct TimeZone : Hashable, Equatable, ReferenceConvertible {
5050
/// An example identifier is "America/Los_Angeles".
5151
///
5252
/// If `identifier` is an unknown identifier, then returns `nil`.
53-
public init?(identifier: String) {
53+
public init?(identifier: __shared String) {
5454
if let r = NSTimeZone(name: identifier) {
5555
_wrapped = r
5656
_autoupdating = false
@@ -83,7 +83,7 @@ public struct TimeZone : Hashable, Equatable, ReferenceConvertible {
8383
///
8484
/// - parameter abbreviation: The abbreviation for the time zone.
8585
/// - returns: A time zone identified by abbreviation determined by resolving the abbreviation to an identifier using the abbreviation dictionary and then returning the time zone for that identifier. Returns `nil` if there is no match for abbreviation.
86-
public init?(abbreviation: String) {
86+
public init?(abbreviation: __shared String) {
8787
if let r = NSTimeZone(abbreviation: abbreviation) {
8888
_wrapped = r
8989
_autoupdating = false

0 commit comments

Comments
 (0)