Swift: Crash with a protocol & Array in one file, two generic structs in another
| Originator: | rix.rob | ||
| Number: | rdar://17657328 | Date Originated: | 13-Jul-2014 09:02 PM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode6-Beta3 (6A254o) |
| Classification: | Serious Bug | Reproducible: | Always |
Summary:
This is a wooly one that I can‘t really describe more succinctly, so just write these files and compile them and enjoy the stack trace.
File one:
protocol C : Collection {}
extension Array : C {}
File two:
struct A<T> {
let a: B<Array<T>>
init() {
a = B()
}
}
struct B<T : Collection> {}
Weirdest corner case I’ve seen yet, but not the only one I’ve seen involving Collection.
Steps to Reproduce:
Put these two files in a project and build.
Expected Results:
I expected it to compile.
Actual Results:
The compiler crashed.
Regression:
There are many workarounds:
1. Put these both into a single file
2. Don’t constrain B<T>’s parameter to Collection
3. Remove A’s property a
4. Parameterize A’s property a by any other type conformed to C
5. Don’t write the init method for A
6. Conform C to Printable instead
7. Don’t conform C to any protocol
8. Don’t extend Array to conform to C
Notes:
Sample project will be uploaded shortly. Thank you for bearing with me.
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!