Xcode-beta (7A165t): [Swift] Structs fail protocol conformity when a property is implemented as a lazy stored property
| Originator: | david.ndh | ||
| Number: | rdar://21966810 | Date Originated: | 23-Jul-2015 08:20 PM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode-beta (7A165t) |
| Classification: | Other Bug | Reproducible: | Always |
Summary:
Structs that conform to a certain protocol should be able to implement properties as lazy stored properties without breaking protocol conformity.
Steps to Reproduce:
1. Declare this
protocol R {
var name: String { get }
}
struct A: R {
lazy var name: String = {
return "John Doe"
}()
}
Expected Results:
Type ’A’ conforms to protocol ‘R’.
Actual Results:
Type ’A’ does not conform to protocol ‘R’.
Regression:
N.A.
Notes:
This only applies to Structs, Classes can implement properties as lazy stored properties without breaking protocol conformity.
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!
I've noticed a similar issue when the protocol declares a function and the struct implements it as being mutating.
You can check this code:
protocol R {
}
struct A: R {
}