Skip to content

Commit f5475a0

Browse files
committed
Make POSIXError use POSIXErrorCode
Don’t define a conflicting and duplicate `POSIXError.Code`
1 parent 70beb7e commit f5475a0

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

Foundation/NSError.swift

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#if canImport(Darwin)
13+
#if canImport(MSVCRT)
14+
import MSVCRT
15+
import WinSDK
16+
#elseif canImport(Darwin)
1417
import Darwin
1518
#elseif canImport(Glibc)
1619
import Glibc
@@ -904,23 +907,12 @@ public struct POSIXError : _BridgedStoredNSError {
904907
}
905908

906909
public static var _nsErrorDomain: String { return NSPOSIXErrorDomain }
910+
911+
public typealias Code = POSIXErrorCode
912+
}
907913

908-
public struct Code: Equatable, Hashable, RawRepresentable, _ErrorCodeProtocol {
909-
public typealias _ErrorType = POSIXError
910-
internal let errorCode: POSIXErrorCode
911-
public var rawValue: Int {
912-
return Int(errorCode.rawValue)
913-
}
914-
public init?(rawValue: Int) {
915-
guard rawValue <= Int(Int32.max),
916-
let errorCode = POSIXErrorCode(rawValue: Int32(rawValue))
917-
else { return nil }
918-
self.init(errorCode: errorCode)
919-
}
920-
internal init(errorCode: POSIXErrorCode) {
921-
self.errorCode = errorCode
922-
}
923-
}
914+
extension POSIXErrorCode: _ErrorCodeProtocol {
915+
public typealias _ErrorType = POSIXError
924916
}
925917

926918
extension POSIXError {

0 commit comments

Comments
 (0)