Skip to content

Commit b86ea32

Browse files
authored
Merge pull request #3132 from compnerd/finalized
Foundation: `final`-ize many bridgeable interfaces
2 parents b8a67da + a303df8 commit b86ea32

25 files changed

+51
-59
lines changed

Sources/Foundation/Bundle.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ private func _getTypeContextDescriptor(of cls: AnyClass) -> UnsafeRawPointer
1414

1515
open class Bundle: NSObject {
1616
private var _bundleStorage: AnyObject!
17-
private var _bundle: CFBundle! {
17+
private final var _bundle: CFBundle! {
1818
get { unsafeBitCast(_bundleStorage, to: CFBundle?.self) }
1919
set { _bundleStorage = newValue }
2020
}

Sources/Foundation/DateFormatter.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
open class DateFormatter : Formatter {
1313
typealias CFType = CFDateFormatter
14-
private var __cfObject: CFType?
15-
private var _cfObject: CFType {
14+
private final var __cfObject: CFType?
15+
private final var _cfObject: CFType {
1616
guard let obj = __cfObject else {
1717
let dateStyle = CFDateFormatterStyle(rawValue: CFIndex(self.dateStyle.rawValue))!
1818
let timeStyle = CFDateFormatterStyle(rawValue: CFIndex(self.timeStyle.rawValue))!
@@ -147,7 +147,7 @@ open class DateFormatter : Formatter {
147147
__cfObject = nil
148148
}
149149

150-
internal func _setFormatterAttributes(_ formatter: CFDateFormatter) {
150+
internal final func _setFormatterAttributes(_ formatter: CFDateFormatter) {
151151
_setFormatterAttribute(formatter, attributeName: kCFDateFormatterIsLenient, value: isLenient._cfObject)
152152
_setFormatterAttribute(formatter, attributeName: kCFDateFormatterTimeZone, value: _timeZone?._cfObject)
153153
if let ident = _calendar?.identifier {
@@ -181,7 +181,7 @@ open class DateFormatter : Formatter {
181181
_setFormatterAttribute(formatter, attributeName: kCFDateFormatterGregorianStartDate, value: _gregorianStartDate?._cfObject)
182182
}
183183

184-
internal func _setFormatterAttribute(_ formatter: CFDateFormatter, attributeName: CFString, value: AnyObject?) {
184+
internal final func _setFormatterAttribute(_ formatter: CFDateFormatter, attributeName: CFString, value: AnyObject?) {
185185
if let value = value {
186186
CFDateFormatterSetProperty(formatter, attributeName, value)
187187
}

Sources/Foundation/DateIntervalFormatter.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ internal extension _CFDateIntervalFormatterBoundaryStyle {
8383
// DateIntervalFormatter returns nil and NO for all methods in Formatter.
8484

8585
open class DateIntervalFormatter: Formatter {
86-
var _core: AnyObject
87-
var core: CFDateIntervalFormatter {
86+
private var _core: AnyObject
87+
private final var core: CFDateIntervalFormatter {
8888
get { unsafeBitCast(_core, to: CFDateIntervalFormatter.self) }
8989
set { _core = newValue }
9090
}

Sources/Foundation/ISO8601DateFormatter.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ extension ISO8601DateFormatter {
5151
open class ISO8601DateFormatter : Formatter, NSSecureCoding {
5252

5353
typealias CFType = CFDateFormatter
54-
private var __cfObject: CFType?
55-
private var _cfObject: CFType {
54+
private final var __cfObject: CFType?
55+
private final var _cfObject: CFType {
5656
guard let obj = __cfObject else {
5757
let format = CFISO8601DateFormatOptions(rawValue: formatOptions.rawValue)
5858
let obj = CFDateFormatterCreateISO8601Formatter(kCFAllocatorSystemDefault, format)!

Sources/Foundation/NSCalendar.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ open class NSCalendar : NSObject, NSCopying, NSSecureCoding {
301301

302302
// Methods to return component name strings localized to the calendar's locale
303303

304-
private func _symbols(_ key: CFString) -> [String] {
304+
private final func _symbols(_ key: CFString) -> [String] {
305305
let dateFormatter = CFDateFormatterCreate(kCFAllocatorSystemDefault, locale?._cfObject, kCFDateFormatterNoStyle, kCFDateFormatterNoStyle)
306306
CFDateFormatterSetProperty(dateFormatter, kCFDateFormatterCalendarKey, _cfObject)
307307
let result = (CFDateFormatterCopyProperty(dateFormatter, key) as! NSArray)._swiftObject
@@ -310,7 +310,7 @@ open class NSCalendar : NSObject, NSCopying, NSSecureCoding {
310310
}
311311
}
312312

313-
private func _symbol(_ key: CFString) -> String {
313+
private final func _symbol(_ key: CFString) -> String {
314314
let dateFormatter = CFDateFormatterCreate(kCFAllocatorSystemDefault, locale?._bridgeToObjectiveC()._cfObject, kCFDateFormatterNoStyle, kCFDateFormatterNoStyle)
315315
CFDateFormatterSetProperty(dateFormatter, kCFDateFormatterCalendarKey, self._cfObject)
316316
return (CFDateFormatterCopyProperty(dateFormatter, key) as! NSString)._swiftObject

Sources/Foundation/NSCharacterSet.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ open class NSCharacterSet : NSObject, NSCopying, NSMutableCopying, NSSecureCodin
7272
return unsafeBitCast(self, to: CFType.self)
7373
}
7474

75-
internal var _cfMutableObject: CFMutableCharacterSet {
75+
internal final var _cfMutableObject: CFMutableCharacterSet {
7676
return unsafeBitCast(self, to: CFMutableCharacterSet.self)
7777
}
7878

Sources/Foundation/NSData.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ open class NSData : NSObject, NSCopying, NSMutableCopying, NSSecureCoding {
7777
private var _deallocHandler: _NSDataDeallocator? = _NSDataDeallocator() // for Swift
7878
private var _bytes: UnsafeMutablePointer<UInt8>? = nil
7979

80-
internal var _cfObject: CFType {
80+
internal final var _cfObject: CFType {
8181
if type(of: self) === NSData.self || type(of: self) === NSMutableData.self {
8282
return unsafeBitCast(self, to: CFType.self)
8383
} else {
@@ -957,7 +957,7 @@ extension CFData : _NSBridgeable, _SwiftBridgeable {
957957

958958
// MARK: -
959959
open class NSMutableData : NSData {
960-
internal var _cfMutableObject: CFMutableData { return unsafeBitCast(self, to: CFMutableData.self) }
960+
internal final var _cfMutableObject: CFMutableData { return unsafeBitCast(self, to: CFMutableData.self) }
961961

962962
public override init() {
963963
super.init(bytes: nil, length: 0)

Sources/Foundation/NSDate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ open class NSDate : NSObject, NSCopying, NSSecureCoding, NSCoding {
5252
_CFDeinit(self)
5353
}
5454

55-
internal var _cfObject: CFType {
55+
internal final var _cfObject: CFType {
5656
return unsafeBitCast(self, to: CFType.self)
5757
}
5858

Sources/Foundation/NSError.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public let NSFilePathErrorKey: String = "NSFilePathErrorKey"
5050
open class NSError : NSObject, NSCopying, NSSecureCoding, NSCoding {
5151
typealias CFType = CFError
5252

53-
internal var _cfObject: CFType {
53+
internal final var _cfObject: CFType {
5454
return CFErrorCreate(kCFAllocatorSystemDefault, domain._cfObject, code, nil)
5555
}
5656

Sources/Foundation/NSKeyedUnarchiver.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ open class NSKeyedUnarchiver : NSCoder {
5656
#endif
5757
}
5858

59-
private var _stream : Stream
59+
private final var _stream : Stream
6060
private var _flags = UnarchiverFlags(rawValue: 0)
6161
private var _containers : Array<DecodingContext>? = nil
6262
private var _objects : Array<Any> = []

0 commit comments

Comments
 (0)