Swift: enum cases should introduce properties
| Originator: | rix.rob | ||
| Number: | rdar://20906767 | Date Originated: | 11-May-2015 06:41 PM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode-beta (6E14) |
| Classification: | Enhancement | Reproducible: | Always |
Summary:
Given a type P and an enum like so:
enum E {
case C(P)
}
E should be given an implicit property of the form:
var c: P? {
switch self {
case let .C(p):
return p
default:
return nil
}
}
I don’t think it’s essential that if P happens to be () then the property be isC: Bool instead, but it might be nice, who knows.
This is dual to projection on tuples (.0, .1, etc) and properties on structs.
Steps to Reproduce:
N/A
Expected Results:
N/A
Actual Results:
N/A
Regression:
N/A
Notes:
N/A
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!