Swift: Crash with protocols, associated types, structs, functions, multiple files, and constants
| Originator: | rix.rob | ||
| Number: | rdar://18405215 | Date Originated: | 20-Sep-2014 09:18 PM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode-Beta (6A1030) |
| Classification: | Serious Bug | Reproducible: | Always |
Summary:
This one is just… well, you’ll see.
Steps to Reproduce:
1. In two different files, write this code:
File one:
protocol P { typealias R }
struct S<U : P> {
let t: U.R
}
func f<T>(t: T) -> S<Q<T>>? {
return nil
}
File two:
struct Q<T> : P { typealias R = T; let t: T }
Expected Results:
Not a crash.
Actual Results:
A crash.
Regression:
Lots of cases where this doesn’t repro:
- change S to a class
- put f and Q in the same file
- remove t from S (i.e. don’t have a constant/variable of the associated type)
- replace t with a func returning e.g. U.R?
- remove f
- change t’s type to U instead of U.R
On the other hand it doesn’t matter if t’s type is U.R, () -> U.R, U.R -> (), or optional variants of any of those.
Notes:
This is significantly reduced from how I encountered it, which is in the Swift version of my testing framework Lagrangian.
Project to follow.
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!