Skip to content

Commit b7d606c

Browse files
committed
SR-8918: warning: conditional cast from 'Any' to 'AnyObject' always succeeds
- The bridging from Any to AnyObject was fixed a while ago so use 'as' instead of 'as?' casting and remove the redundant else case.
1 parent beb667d commit b7d606c

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

Foundation/UserDefaults.swift

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,8 @@ private var registeredDefaults = [String: Any]()
1313
private var sharedDefaults = UserDefaults()
1414

1515
fileprivate func bridgeFromNSCFTypeIfNeeded(_ value: Any) -> Any {
16-
// This line will produce a 'Conditional cast always succeeds' warning if compiled on Darwin, since Darwin has bridging casts of any value to an object,
17-
// but is required for non-Darwin to work correctly, since that platform _doesn't_ have bridging casts of that kind for now.
18-
if let object = value as? AnyObject {
19-
return __SwiftValue.fetch(nonOptional: object)
20-
} else {
21-
return value
22-
}
16+
let object = value as AnyObject
17+
return __SwiftValue.fetch(nonOptional: object)
2318
}
2419

2520
open class UserDefaults: NSObject {

0 commit comments

Comments
 (0)