Skip to content

Commit 0bcf4e6

Browse files
committed
[SE-0112] Sink RawRepresentable down into _BridgedNSError.
This is part of loosening _BridgedNSError up a bit, so it can work with error types that directly embed an NSError instance.
1 parent a428452 commit 0bcf4e6

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

stdlib/public/SDK/Foundation/NSError.swift

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -249,17 +249,18 @@ public func _stdlib_bridgeNSErrorToErrorProtocol<
249249

250250
/// Helper protocol for _BridgedNSError, which used to provide
251251
/// default implementations.
252-
public protocol __BridgedNSError : RawRepresentable, ErrorProtocol {
252+
public protocol __BridgedNSError : ErrorProtocol {
253253
static var _nsErrorDomain: String { get }
254254
}
255255

256256
// Allow two bridged NSError types to be compared.
257257
public func ==<T: __BridgedNSError>(lhs: T, rhs: T) -> Bool
258-
where T.RawValue: SignedInteger {
258+
where T: RawRepresentable, T.RawValue: SignedInteger {
259259
return lhs.rawValue.toIntMax() == rhs.rawValue.toIntMax()
260260
}
261261

262-
public extension __BridgedNSError where RawValue: SignedInteger {
262+
public extension __BridgedNSError
263+
where Self: RawRepresentable, Self.RawValue: SignedInteger {
263264
public final var _domain: String { return Self._nsErrorDomain }
264265
public final var _code: Int { return Int(rawValue.toIntMax()) }
265266

@@ -280,12 +281,13 @@ public extension __BridgedNSError where RawValue: SignedInteger {
280281

281282
// Allow two bridged NSError types to be compared.
282283
public func ==<T: __BridgedNSError>(lhs: T, rhs: T) -> Bool
283-
where T.RawValue: UnsignedInteger {
284+
where T: RawRepresentable, T.RawValue: UnsignedInteger {
284285
return lhs.rawValue.toUIntMax() == rhs.rawValue.toUIntMax()
285286
}
286287

287288

288-
public extension __BridgedNSError where RawValue: UnsignedInteger {
289+
public extension __BridgedNSError
290+
where Self: RawRepresentable, Self.RawValue: UnsignedInteger {
289291
public final var _domain: String { return Self._nsErrorDomain }
290292
public final var _code: Int {
291293
return Int(bitPattern: UInt(rawValue.toUIntMax()))
@@ -312,14 +314,14 @@ public extension __BridgedNSError where RawValue: UnsignedInteger {
312314
/// This protocol is used primarily to generate the conformance to
313315
/// _ObjectiveCBridgeableErrorProtocol for such an enum.
314316
public protocol _BridgedNSError : __BridgedNSError,
317+
RawRepresentable,
315318
_ObjectiveCBridgeableErrorProtocol,
316319
Hashable {
317320
/// The NSError domain to which this type is bridged.
318321
static var _nsErrorDomain: String { get }
319322
}
320323

321-
/// Enumeration that describes the error codes within the Cocoa error
322-
/// domain.
324+
/// Describes errors within the Cocoa error domain.
323325
public struct NSCocoaError : RawRepresentable, _BridgedNSError {
324326
public let rawValue: Int
325327

0 commit comments

Comments
 (0)