Skip to content

Commit b16c8d2

Browse files
committed
Use a regular downcast instead of an unsafe downcast for Error to NSError conversion (#5221)
1 parent 51be7d1 commit b16c8d2

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)