Swift: Spurious error when iterating element-constrained Sliceable
| Originator: | rix.rob | ||
| Number: | rdar://19336021 | Date Originated: | 23-Dec-2014 10:42 AM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode 6.1.1 (6A2008a) |
| Classification: | Other Bug | Reproducible: | Always |
Summary:
A Sliceable whose elements are constrained to be of a specific type involving other type parameters cannot be iterated with for/in.
Steps to Reproduce:
1. Write this:
struct A<T, U> {}
func f<T, U, S: Sliceable where S.Generator.Element == A<T, U>>(xs: S) -> () {
for _ in xs {}
}
Expected Results:
I expected it to compile.
Actual Results:
Nope:
error: cannot convert the expression's type 'S' to type 'A<$T4, $T5>'
Regression:
You can write a recursive function for this if the Sliceable is recursive, but you may crash the compiler: rdar://19335891
Notes:
N/A
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!