Skip to content

Commit 958a93e

Browse files
jrose-appleparkera
authored andcommitted
Update for SE-0025 ('private' and 'fileprivate') (#445)
1 parent f4729b9 commit 958a93e

17 files changed

+61
-61
lines changed

Foundation/Boxing.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
///
1515
/// Note: This assumes that the result of calling copy() is mutable. The documentation says that classes which do not have a mutable/immutable distinction should just adopt NSCopying instead of NSMutableCopying.
1616
internal final class _MutableHandle<MutableType : NSObject where MutableType : NSCopying> {
17-
private var _pointer : MutableType
17+
fileprivate var _pointer : MutableType
1818

1919
init(reference : MutableType) {
2020
_pointer = reference.copy() as! MutableType

Foundation/Data.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public struct Data : ReferenceConvertible, CustomStringConvertible, Equatable, H
163163
/// A custom deallocator.
164164
case custom((UnsafeMutablePointer<UInt8>, Int) -> Void)
165165

166-
private var _deallocator : ((UnsafeMutablePointer<Void>, Int) -> Void)? {
166+
fileprivate var _deallocator : ((UnsafeMutablePointer<Void>, Int) -> Void)? {
167167
switch self {
168168
case .unmap:
169169
return { __NSDataInvokeDeallocatorUnmap($0, $1) }

Foundation/IndexPath.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public struct IndexPath : ReferenceConvertible, Equatable, Hashable, MutableColl
2424
public typealias Index = Array<Int>.Index
2525
public typealias Indices = DefaultRandomAccessIndices<IndexPath>
2626

27-
private var _indexes : Array<Int>
27+
fileprivate var _indexes : Array<Int>
2828

2929
/// Initialize an empty index path.
3030
public init() {
@@ -153,7 +153,7 @@ public struct IndexPath : ReferenceConvertible, Equatable, Hashable, MutableColl
153153

154154
// MARK: - Bridging Helpers
155155

156-
private init(nsIndexPath: ReferenceType) {
156+
fileprivate init(nsIndexPath: ReferenceType) {
157157
let count = nsIndexPath.length
158158
if count == 0 {
159159
_indexes = []
@@ -168,7 +168,7 @@ public struct IndexPath : ReferenceConvertible, Equatable, Hashable, MutableColl
168168
}
169169
}
170170

171-
private func makeReference() -> ReferenceType {
171+
fileprivate func makeReference() -> ReferenceType {
172172
return _indexes.withUnsafeBufferPointer {
173173
return ReferenceType(indexes: $0.baseAddress!, length: $0.count)
174174
}

Foundation/IndexSet.swift

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@ public struct IndexSet : ReferenceConvertible, Equatable, BidirectionalCollectio
9696
public let startIndex : Index
9797
public let endIndex : Index
9898

99-
private var indexSet : IndexSet
99+
fileprivate var indexSet : IndexSet
100100

101101
// Range of element values
102102
private var intersectingRange : Range<IndexSet.Element>?
103103

104-
private init(indexSet : IndexSet, intersecting range : Range<IndexSet.Element>?) {
104+
fileprivate init(indexSet : IndexSet, intersecting range : Range<IndexSet.Element>?) {
105105
self.indexSet = indexSet
106106
self.intersectingRange = range
107107

@@ -165,21 +165,21 @@ public struct IndexSet : ReferenceConvertible, Equatable, BidirectionalCollectio
165165

166166
/// The mechanism for getting to the integers stored in an IndexSet.
167167
public struct Index : CustomStringConvertible, Comparable {
168-
private let indexSet : IndexSet
169-
private var value : IndexSet.Element
170-
private var extent : Range<IndexSet.Element>
171-
private var rangeIndex : Int
172-
private let rangeCount : Int
168+
fileprivate let indexSet : IndexSet
169+
fileprivate var value : IndexSet.Element
170+
fileprivate var extent : Range<IndexSet.Element>
171+
fileprivate var rangeIndex : Int
172+
fileprivate let rangeCount : Int
173173

174-
private init(firstIn indexSet : IndexSet) {
174+
fileprivate init(firstIn indexSet : IndexSet) {
175175
self.indexSet = indexSet
176176
self.rangeCount = indexSet._rangeCount
177177
self.rangeIndex = 0
178178
self.extent = indexSet._range(at: 0)
179179
self.value = extent.lowerBound
180180
}
181181

182-
private init(lastIn indexSet : IndexSet) {
182+
fileprivate init(lastIn indexSet : IndexSet) {
183183
self.indexSet = indexSet
184184
let rangeCount = indexSet._rangeCount
185185
self.rangeIndex = rangeCount - 1
@@ -193,7 +193,7 @@ public struct IndexSet : ReferenceConvertible, Equatable, BidirectionalCollectio
193193
self.rangeCount = rangeCount
194194
}
195195

196-
private init(indexSet: IndexSet, index: Int) {
196+
fileprivate init(indexSet: IndexSet, index: Int) {
197197
self.indexSet = indexSet
198198
self.rangeCount = self.indexSet._rangeCount
199199
self.value = index
@@ -207,7 +207,7 @@ public struct IndexSet : ReferenceConvertible, Equatable, BidirectionalCollectio
207207
}
208208

209209
// First or last value in a specified range
210-
private init(indexSet: IndexSet, rangeIndex: Int, rangeCount: Int, first : Bool) {
210+
fileprivate init(indexSet: IndexSet, rangeIndex: Int, rangeCount: Int, first : Bool) {
211211
self.indexSet = indexSet
212212
let extent = indexSet._range(at: rangeIndex)
213213
if first {
@@ -220,15 +220,15 @@ public struct IndexSet : ReferenceConvertible, Equatable, BidirectionalCollectio
220220
self.rangeIndex = rangeIndex
221221
}
222222

223-
private init(indexSet: IndexSet, value: Int, extent: Range<Int>, rangeIndex: Int, rangeCount: Int) {
223+
fileprivate init(indexSet: IndexSet, value: Int, extent: Range<Int>, rangeIndex: Int, rangeCount: Int) {
224224
self.indexSet = indexSet
225225
self.value = value
226226
self.extent = extent
227227
self.rangeCount = rangeCount
228228
self.rangeIndex = rangeIndex
229229
}
230230

231-
private func successor() -> Index {
231+
fileprivate func successor() -> Index {
232232
if value + 1 == extent.upperBound {
233233
// Move to the next range
234234
if rangeIndex + 1 == rangeCount {
@@ -243,7 +243,7 @@ public struct IndexSet : ReferenceConvertible, Equatable, BidirectionalCollectio
243243
}
244244
}
245245

246-
private mutating func _successorInPlace() {
246+
fileprivate mutating func _successorInPlace() {
247247
if value + 1 == extent.upperBound {
248248
// Move to the next range
249249
if rangeIndex + 1 == rangeCount {
@@ -260,7 +260,7 @@ public struct IndexSet : ReferenceConvertible, Equatable, BidirectionalCollectio
260260
}
261261
}
262262

263-
private func predecessor() -> Index {
263+
fileprivate func predecessor() -> Index {
264264
if value == extent.lowerBound {
265265
// Move to the next range
266266
if rangeIndex == 0 {
@@ -279,7 +279,7 @@ public struct IndexSet : ReferenceConvertible, Equatable, BidirectionalCollectio
279279
return "index \(value) in a range of \(extent) [range #\(rangeIndex + 1)/\(rangeCount)]"
280280
}
281281

282-
private mutating func _predecessorInPlace() {
282+
fileprivate mutating func _predecessorInPlace() {
283283
if value == extent.lowerBound {
284284
// Move to the next range
285285
if rangeIndex == 0 {
@@ -299,7 +299,7 @@ public struct IndexSet : ReferenceConvertible, Equatable, BidirectionalCollectio
299299
public typealias ReferenceType = NSIndexSet
300300
public typealias Element = Int
301301

302-
private var _handle: _MutablePairHandle<NSIndexSet, NSMutableIndexSet>
302+
fileprivate var _handle: _MutablePairHandle<NSIndexSet, NSMutableIndexSet>
303303

304304
internal init(indexesIn range: NSRange) {
305305
_handle = _MutablePairHandle(NSIndexSet(indexesIn: range), copying: false)
@@ -691,18 +691,18 @@ public struct IndexSet : ReferenceConvertible, Equatable, BidirectionalCollectio
691691

692692
// MARK: - Bridging Support
693693

694-
private var reference: NSIndexSet {
694+
fileprivate var reference: NSIndexSet {
695695
return _handle.reference
696696
}
697697

698-
private init(reference: NSIndexSet) {
698+
fileprivate init(reference: NSIndexSet) {
699699
_handle = _MutablePairHandle(reference)
700700
}
701701
}
702702

703703
/// Iterate two index sets on the boundaries of their ranges. This is where all of the interesting stuff happens for exclusive or, intersect, etc.
704704
private struct IndexSetBoundaryIterator : IteratorProtocol {
705-
private typealias Element = IndexSet.Element
705+
fileprivate typealias Element = IndexSet.Element
706706

707707
private var i1 : IndexSet.RangeView.Iterator
708708
private var i2 : IndexSet.RangeView.Iterator
@@ -711,7 +711,7 @@ private struct IndexSetBoundaryIterator : IteratorProtocol {
711711
private var i1UsedLower : Bool
712712
private var i2UsedLower : Bool
713713

714-
private init(_ is1 : IndexSet, _ is2 : IndexSet) {
714+
fileprivate init(_ is1 : IndexSet, _ is2 : IndexSet) {
715715
i1 = is1.rangeView().makeIterator()
716716
i2 = is2.rangeView().makeIterator()
717717

@@ -723,7 +723,7 @@ private struct IndexSetBoundaryIterator : IteratorProtocol {
723723
i2UsedLower = false
724724
}
725725

726-
private mutating func next() -> Element? {
726+
fileprivate mutating func next() -> Element? {
727727
if i1Range == nil && i2Range == nil {
728728
return nil
729729
}
@@ -817,7 +817,7 @@ private enum _MutablePair<ImmutableType, MutableType> {
817817
///
818818
/// a.k.a. Box
819819
private final class _MutablePairHandle<ImmutableType : NSObject, MutableType : NSObject where ImmutableType : NSMutableCopying, MutableType : NSMutableCopying> {
820-
private var _pointer: _MutablePair<ImmutableType, MutableType>
820+
fileprivate var _pointer: _MutablePair<ImmutableType, MutableType>
821821

822822
/// Initialize with an immutable reference instance.
823823
///

Foundation/NSAttributedString.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import CoreFoundation
1212
public class AttributedString: NSObject, NSCopying, NSMutableCopying, NSSecureCoding {
1313

1414
private let _cfinfo = _CFInfo(typeID: CFAttributedStringGetTypeID())
15-
private var _string: NSString
16-
private var _attributeArray: CFRunArrayRef
15+
fileprivate var _string: NSString
16+
fileprivate var _attributeArray: CFRunArrayRef
1717

1818
public required init?(coder aDecoder: NSCoder) {
1919
NSUnimplemented()
@@ -111,13 +111,13 @@ public class AttributedString: NSObject, NSCopying, NSMutableCopying, NSSecureCo
111111
}
112112

113113
private extension AttributedString {
114-
private struct RangeInfo {
114+
fileprivate struct RangeInfo {
115115
let rangePointer: NSRangePointer
116116
let shouldFetchLongestEffectiveRange: Bool
117117
let longestEffectiveRangeSearchRange: NSRange?
118118
}
119119

120-
private func _attributesAtIndex(_ location: Int, rangeInfo: RangeInfo) -> [String : AnyObject] {
120+
fileprivate func _attributesAtIndex(_ location: Int, rangeInfo: RangeInfo) -> [String : AnyObject] {
121121
var cfRange = CFRange()
122122
return withUnsafeMutablePointer(&cfRange) { (cfRangePointer: UnsafeMutablePointer<CFRange>) -> [String : AnyObject] in
123123
// Get attributes value using CoreFoundation function
@@ -147,7 +147,7 @@ private extension AttributedString {
147147
}
148148
}
149149

150-
private func _attribute(_ attrName: String, atIndex location: Int, rangeInfo: RangeInfo) -> AnyObject? {
150+
fileprivate func _attribute(_ attrName: String, atIndex location: Int, rangeInfo: RangeInfo) -> AnyObject? {
151151
var cfRange = CFRange()
152152
return withUnsafeMutablePointer(&cfRange) { (cfRangePointer: UnsafeMutablePointer<CFRange>) -> AnyObject? in
153153
// Get attribute value using CoreFoundation function
@@ -171,7 +171,7 @@ private extension AttributedString {
171171
}
172172
}
173173

174-
private func addAttributesToAttributeArray(attrs: [String : AnyObject]?) {
174+
fileprivate func addAttributesToAttributeArray(attrs: [String : AnyObject]?) {
175175
guard _string.length > 0 else {
176176
return
177177
}

Foundation/NSGeometry.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public struct CGFloat {
3232
/// The native value.
3333
public var native: NativeType
3434

35-
private var hash: Int {
35+
fileprivate var hash: Int {
3636
#if arch(i386) || arch(arm)
3737
return Int(Float(self.native).bitPattern)
3838
#else

Foundation/NSKeyedUnarchiver.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ public class NSKeyedUnarchiver : NSCoder {
2323
}
2424

2525
class DecodingContext {
26-
private var dict : Dictionary<String, Any>
27-
private var genericKey : UInt = 0
26+
fileprivate var dict : Dictionary<String, Any>
27+
fileprivate var genericKey : UInt = 0
2828

2929
init(_ dict : Dictionary<String, Any>) {
3030
self.dict = dict

Foundation/NSNotification.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,10 @@ extension NSNotification {
107107
}
108108

109109
private class NSNotificationReceiver : NSObject {
110-
private weak var object: NSObject?
111-
private var name: Notification.Name?
112-
private var block: ((Notification) -> Void)?
113-
private var sender: AnyObject?
110+
fileprivate weak var object: NSObject?
111+
fileprivate var name: Notification.Name?
112+
fileprivate var block: ((Notification) -> Void)?
113+
fileprivate var sender: AnyObject?
114114
}
115115

116116
extension Sequence where Iterator.Element : NSNotificationReceiver {
@@ -122,7 +122,7 @@ extension Sequence where Iterator.Element : NSNotificationReceiver {
122122
/// - elements that property `name` is not equal to parameter `name` if specified.
123123
/// - elements that property `sender` is not equal to parameter `object` if specified.
124124
///
125-
private func filterOutObserver(_ observerToFilter: AnyObject, name:Notification.Name? = nil, object: AnyObject? = nil) -> [Iterator.Element] {
125+
fileprivate func filterOutObserver(_ observerToFilter: AnyObject, name:Notification.Name? = nil, object: AnyObject? = nil) -> [Iterator.Element] {
126126
return self.filter { observer in
127127

128128
let differentObserver = observer.object !== observerToFilter
@@ -141,7 +141,7 @@ extension Sequence where Iterator.Element : NSNotificationReceiver {
141141
/// - elements that property `sender` is `nil` or equals specified parameter `sender`.
142142
/// - elements that property `name` is `nil` or equals specified parameter `name`.
143143
///
144-
private func observersMatchingName(_ name:Notification.Name? = nil, sender: AnyObject? = nil) -> [Iterator.Element] {
144+
fileprivate func observersMatchingName(_ name:Notification.Name? = nil, sender: AnyObject? = nil) -> [Iterator.Element] {
145145
return self.filter { observer in
146146

147147
let emptyName = observer.name == nil

Foundation/NSOrderedSet.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public class NSOrderedSet : NSObject, NSCopying, NSMutableCopying, NSSecureCodin
108108
return objectAtIndex(idx)
109109
}
110110

111-
private func _insertObject(_ object: AnyObject) {
111+
fileprivate func _insertObject(_ object: AnyObject) {
112112
guard !containsObject(object), let object = object as? NSObject else {
113113
return
114114
}
@@ -117,7 +117,7 @@ public class NSOrderedSet : NSObject, NSCopying, NSMutableCopying, NSSecureCodin
117117
_orderedStorage.append(object)
118118
}
119119

120-
private func _insertObjects(_ objects: UnsafePointer<AnyObject?>, count cnt: Int) {
120+
fileprivate func _insertObjects(_ objects: UnsafePointer<AnyObject?>, count cnt: Int) {
121121
let buffer = UnsafeBufferPointer(start: objects, count: cnt)
122122
for obj in buffer {
123123
_insertObject(obj!)
@@ -371,7 +371,7 @@ public class NSMutableOrderedSet : NSOrderedSet {
371371

372372
public required init?(coder aDecoder: NSCoder) { NSUnimplemented() }
373373

374-
private func _removeObject(_ object: AnyObject) {
374+
fileprivate func _removeObject(_ object: AnyObject) {
375375
guard containsObject(object), let object = object as? NSObject else {
376376
return
377377
}

Foundation/NSTask.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public class Task: NSObject {
176176
private var runLoopSourceContext : CFRunLoopSourceContext?
177177
private var runLoopSource : CFRunLoopSource?
178178

179-
private weak var runLoop : RunLoop? = nil
179+
fileprivate weak var runLoop : RunLoop? = nil
180180

181181
private var processLaunchedCondition = Condition()
182182

Foundation/NSURL.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ extension NSURL {
788788
return URL(fileURLWithPath: resolvedPath)
789789
}
790790

791-
private func _pathByRemovingDots(_ comps: [String]) -> String {
791+
fileprivate func _pathByRemovingDots(_ comps: [String]) -> String {
792792
var components = comps
793793

794794
if(components.last == "/") {

Foundation/NSXMLNode.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -883,8 +883,8 @@ internal protocol _NSXMLNodeCollectionType: Collection { }
883883
extension XMLNode: _NSXMLNodeCollectionType {
884884

885885
public struct Index: Comparable {
886-
private let node: _CFXMLNodePtr?
887-
private let offset: Int?
886+
fileprivate let node: _CFXMLNodePtr?
887+
fileprivate let offset: Int?
888888
}
889889

890890
public subscript(index: Index) -> XMLNode {

Foundation/NSXMLParser.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ public class XMLParser : NSObject {
404404
internal var _chunkSize = Int(4096 * 32) // a suitably large number for a decent chunk size
405405
internal var _haveDetectedEncoding = false
406406
internal var _bomChunk: Data?
407-
private var _parserContext: _CFXMLInterfaceParserContext?
407+
fileprivate var _parserContext: _CFXMLInterfaceParserContext?
408408
internal var _delegateAborted = false
409409
internal var _url: URL?
410410
internal var _namespaces = [[String:String]]()

Foundation/String.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ extension String {
7575
/// representation.
7676
func _index(_ utf16Index: Int) -> Index {
7777
return Index(
78-
_base: String.UnicodeScalarView.Index(_position: utf16Index),
79-
in: characters
80-
)
78+
String.UTF16View.Index(utf16Index),
79+
within: self
80+
)!
8181
}
8282

8383
/// Return a `Range<Index>` corresponding to the given `NSRange` of

0 commit comments

Comments
 (0)