Swift: A constant inside a class cannot refer to another constant in that class
| Originator: | |||
| Number: | rdar://17251139 | Date Originated: | 2014-06-10 |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | |
| Classification: | Reproducible: |
Summary:
This does not work:
import Cocoa
class MyClass {
let color1 = NSColor.whiteColor()
let color2 = color1 // MyClass.Type does not have a member color1
}
But this does work:
class MyClass {
let color1 = NSColor.whiteColor()
let color2: NSColor
init() {
color2 = color1
}
}
Steps to Reproduce:
See above.
Expected Results:
I'd expect to be able to make one constant refer to another in their declarations.
Actual Results:
Compiler error: it does not recognize the color1 field.
Version:
Xcode 6 beta 1
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!