Cannot call function with Generator of an Array of a protocol
| Originator: | martin.kuehl | ||
| Number: | rdar://23462662 | Date Originated: | 11/09/2015 |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | |
| Classification: | Enhancement | Reproducible: | Always |
Summary:
See the attached code.
Steps to Reproduce:
1. Open the attached code
2. Compile
Expected Results:
The code compiles.
Actual Results:
The call from `foo` to `bar` fails to compile with “Cannot invoke 'bar' wiht an argument list of type '(IndexingGenerator<[P]>)'”.
Version:
Notes:
Configuration:
ProductName: Mac OS X
ProductVersion: 10.10.5
BuildVersion: 14F1021
Xcode 7.1
Build version 7B91b
Apple Swift version 2.1 (swiftlang-700.1.101.6 clang-700.1.76)
Target: x86_64-apple-darwin14.5.0
Attachments:
'Sample.playground.zip' was successfully uploaded.
protocol P {}
func foo(ps: [P]) {
bar(ps.generate())
}
func bar<G: GeneratorType where G.Element: P>(g: G) {
print(g)
}
func baz<T: P>(ts: [T]) {
bar(ts.generate())
}
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!