Skip to content

Commit fc99de4

Browse files
authored
Foundation: resolve some warnings (#16078)
- JSONEncoder.swift: tell the compiler that yes, this is supposed to be casting to 'T' and not 'T?'. - NSObject.swift: mark NSKeyValueObservation members explicitly @objc and @nonobjc. - NSStringAPI.swift: remove unnecessary @usableFromInline. No intended functionality change.
1 parent 460fccb commit fc99de4

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

stdlib/public/SDK/Foundation/JSONEncoder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2374,7 +2374,7 @@ extension _JSONDecoder {
23742374
debugDescription: "Invalid URL string."))
23752375
}
23762376

2377-
return url as! T
2377+
return (url as! T)
23782378
} else if type == Decimal.self || type == NSDecimalNumber.self {
23792379
return try self.unbox(value, as: Decimal.self) as? T
23802380
} else {

stdlib/public/SDK/Foundation/NSObject.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,12 @@ func _bridgeStringToKeyPath(_ keyPath:String) -> AnyKeyPath? {
130130

131131
public class NSKeyValueObservation : NSObject {
132132

133-
weak var object : NSObject?
134-
let callback : (NSObject, NSKeyValueObservedChange<Any>) -> Void
135-
let path : String
133+
@nonobjc weak var object : NSObject?
134+
@nonobjc let callback : (NSObject, NSKeyValueObservedChange<Any>) -> Void
135+
@nonobjc let path : String
136136

137137
//workaround for <rdar://problem/31640524> Erroneous (?) error when using bridging in the Foundation overlay
138-
static var swizzler : NSKeyValueObservation? = {
138+
@nonobjc static var swizzler : NSKeyValueObservation? = {
139139
let bridgeClass: AnyClass = NSKeyValueObservation.self
140140
let observeSel = #selector(NSObject.observeValue(forKeyPath:of:change:context:))
141141
let swapSel = #selector(NSKeyValueObservation._swizzle_me_observeValue(forKeyPath:of:change:context:))
@@ -157,7 +157,7 @@ public class NSKeyValueObservation : NSObject {
157157
}
158158

159159
///invalidate() will be called automatically when an NSKeyValueObservation is deinited
160-
public func invalidate() {
160+
@objc public func invalidate() {
161161
object?.removeObserver(self, forKeyPath: path, context: nil)
162162
object = nil
163163
}

0 commit comments

Comments
 (0)