Skip to content

Commit 7ae6266

Browse files
authored
Use a regular downcast instead of an unsafe downcast for Error to NSError conversion (#5221) (#5222)
1 parent 7875139 commit 7ae6266

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Sources/Foundation/NSError.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -891,8 +891,8 @@ func _convertNSErrorToError(_ error: NSError?) -> Error {
891891

892892
public // COMPILER_INTRINSIC
893893
func _convertErrorToNSError(_ error: Error) -> NSError {
894-
if let object = _extractDynamicValue(error as Any) {
895-
return unsafeDowncast(object, to: NSError.self)
894+
if let object = _extractDynamicValue(error as Any), let asNS = object as? NSError {
895+
return asNS
896896
} else {
897897
let domain: String
898898
let code: Int

0 commit comments

Comments
 (0)