Add support for stored type properties in Swift classes
| Originator: | gmws82 | ||
| Number: | rdar://17478424 | Date Originated: | 6/26/14 |
| Status: | Open | Resolved: | No |
| Product: | Developer Tools | Product Version: | Xcode 6.0 (6A215l) |
| Classification: | Enhancement | Reproducible: | N/A |
Summary:
The Swift Programming Language book says the following, in the “Type Properties” subsection of the “Properties” chapter: “For value types (that is, structures and enumerations), you can define stored and computed type properties. For classes, you can define computed type properties only.”
No reason is given for this omission, and when attempting to create a stored type property in a Swift class in the Xcode 6 beta, the compiler gives the error, “Class variables not yet supported”, indicating that this omission is temporary.
Working around this omission is easy, but inconsistent with the otherwise impeccably elegant nature of the Swift language. Please add support for stored type properties to classes in Swift.
Steps to Reproduce:
Create a new Swift playground in Xcode, and attempt to use the following syntax:
class SomeClass {
class var storedTypeProperty = "Some value."
}
Expected Results:
storedTypeProperty is a stored type property of SomeClass.
Actual Results:
Compiler gives error: “Class variables not yet supported”.
Notes:
See: http://stackoverflow.com/questions/24029581/why-no-stored-type-properties-for-classes-in-swift and http://stackoverflow.com/questions/24015207/class-variables-not-yet-supported
Configuration:
This feature is not present in the Swift programming language as of 6/26/14, Xcode Version 6.0 (6A215l).
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!