Swift 2b4: Pointfree reference to generic initializer in generic context does not compile
| Originator: | rix.rob | ||
| Number: | rdar://21928143 | Date Originated: | 21-Jul-2015 05:30 PM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode-beta (7A165t) |
| Classification: | Other Bug | Reproducible: | Always |
Summary:
String.init works fine when the type it’s being applied to is well-known, but doesn’t seem to in a generic context.
Steps to Reproduce:
1. This code:
extension Array {
func f() -> String {
return ", ".join(lazy(self).map(String.init))
}
}
Expected Results:
should compile
Actual Results:
but totally doesn’t:
rob@Resonance ~/Desktop> swiftc boom.swift
boom.swift:3:42: error: could not find an overload for 'String.init' that accepts the supplied arguments
return ", ".join(lazy(self).map(String.init))
~~~~~~~^~~~
Regression:
It works fine if the type is known statically:
extension Array {
func f() -> String {
return ", ".join(lazy([1, 2, 3]).map(String.init))
}
}
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!
Probably due to the overlapping generic init(_:) definitions
The following does compile:
which calls this
String.initoverload:That suggests to me that swiftc is unable to figure out you'd want to unconditionally (?) call:
in your Array extension.