Open
Description
Previous ID | SR-15841 |
Radar | None |
Original Reporter | @NachoSoto |
Type | Bug |
Environment
Xcode Version 13.2.1 (13C100)
swift-driver version: 1.26.21
Apple Swift version 5.5.2 (swiftlang-1300.0.47.5 clang-1300.0.29.30)
Additional Detail from JIRA
Votes | 1 |
Component/s | Compiler, Foundation |
Labels | Bug |
Assignee | None |
Priority | Medium |
md5: 2895ace0598550fb916de3edc41de116
Issue Description:
Consider a sample error:
enum E: Int, Error {
case e1
}
extension E: CustomNSError {
static let errorDomain: String = "DOMAIN"
}
The following will correctly print "Error DOMAIN:0":
let e = E.e1 as NSError
print("Error \(e.domain):\(e.code)")
However, making the type `@objc` will break this behavior:
@objc(TheError)
enum E: Int, Error {
case e1
}
extension E: CustomNSError {
static let errorDomain: String = "DOMAIN"
}
The printed error now becomes:
Error StoreKitTest.E:0
A workaround would be to override `_nsErrorDomain`, and while that would work for Swift, the auto-generated `TheErrorDomain` (which comes from the `@objc` name + `Domain`) would still be "StoreKitTest.E` instead of the overridden value.