[stdlib] Backward compatibility fix for a flatMap on [String]#9466
Merged
airspeedswift merged 2 commits intoswiftlang:masterfrom May 11, 2017
moiseev:flatmap-string
Merged
[stdlib] Backward compatibility fix for a flatMap on [String]#9466airspeedswift merged 2 commits intoswiftlang:masterfrom moiseev:flatmap-string
airspeedswift merged 2 commits intoswiftlang:masterfrom
moiseev:flatmap-string
Conversation
Contributor
Author
|
/cc @dabrahams , @airspeedswift |
Contributor
Author
|
@swift-ci Please test |
Contributor
Author
|
@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>
Contributor
Author
|
@swift-ci Please smoke test |
Contributor
Author
|
@swift-ci Please Test Source Compatibility |
Contributor
Author
|
@swift-ci Please Test Source Compatibility |
Contributor
Author
|
@swift-ci Please smoke test |
Contributor
Can someone fill http://www.openradar.me/32024978 or provide a public resource? |
Contributor
Author
|
@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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since
Stringstarted to conform toCollection, theflatMapwith 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