Xcode-beta (7A192o): Using Instance Fields in Lazy Evaluation in Swift

Originator:john
Number:rdar://22595509 Date Originated:06-Sep-2015 09:58 AM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode-beta (7A192o)
Classification:Feature (New) Reproducible:Always
 
Summary:
The code for lazy initialization of a field seems to run at the class level rather than the instance level. This means that a lazy field initializer cannot reference other fields, which prevents more complicated relationships among lazy field. This is particularly a problem for types that do not use normal initialization, like types that are initialized from NIBs, or test classes.

Steps to Reproduce:
1. Create a class with a lazily initialized field
2. Add another lazily initialized field that is based off of the value form the first field

Expected Results:
The second field would get a value based off of the value in the first field the first time the second field is accessed.

Actual Results:
The compiler complains that the first field doesn’t exist.

Regression:

Notes:

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!