Swift: Poor error message when trying to conform an enum to a protocol with a class method
| Originator: | getaaron | ||
| Number: | rdar://18997704 | Date Originated: | 11/16/2014 |
| Status: | Open | Resolved: | |
| Product: | iOS SDK | Product Version: | iOS 8.1 GM |
| Classification: | Performance | Reproducible: | Always |
Summary:
If a protocol has a class method, and the enum attempts to conform to the protocol, the error messaging is unintuitive.
Steps to Reproduce:
Paste this code into Playground:
protocol MyProtocol {
class func myFunc() -> Int
}
enum MyEnum: Int, MyProtocol {
case A
case B
static func myFunc() -> Int { return A.rawValue }
}
let foo: MyProtocol.Type = MyEnum.self
let bar = foo.myFunc()
Expected Results:
I expect an error like "MyEnum cannot conform to MyProtocol because MyProtocol includes a class method, which enums don't support."
Actual Results:
I see the error "Accessing members of protocol type value 'MyProtocol.Type' is unimplemented".
Version:
iOS 8.1 GM
Notes:
The error message is slightly clearer if you use "class" instead of "static" within the enum, but it still could be much clearer.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!