New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[stdlib] Backward compatibility fix for a flatMap on [String] #9466
Conversation
/cc @dabrahams , @airspeedswift |
@swift-ci Please test |
@swift-ci Please Test Source Compatibility |
Since String started to conform to Collection, the flatMap with a sequence returning closure is now a better match that the one that relies on the optional promotion in this code: [""].flatMap { $0 } which results in the default type of this expression changing from [String] to [Character]. Restoring the old behavior in Swift 3 mode by adding a very explicit overload. Fixes: <rdar://problem/32024978>
@swift-ci Please smoke test |
@swift-ci Please Test Source Compatibility |
@swift-ci Please Test Source Compatibility |
@swift-ci Please smoke test |
Can someone fill http://www.openradar.me/32024978 or provide a public resource? |
@Coeur The description of this PR explains it, doesn't it? The following code: struct S { var p: String }
func f(xs: [S]) -> [String] {
return xs.flatMap { $0.p }
} would not compile once |
Since
String
started to conform toCollection
, theflatMap
with asequence returning closure is now a better match than the one that
relies on the optional promotion in this code:
which results in the default type of this expression changing from
[String]
to[Character]
.Restoring the old behavior in Swift 3 mode by adding a very explicit
overload.
Fixes: rdar://problem/32024978