Skip to content

Commit b9ed475

Browse files
author
Max Moiseev
committed
[stdlib] Remove the unnecessary compactMap overload
This particular overload of compactMap was mechanically copied from the `flatMap` while implementing SE-0187, but as community members correctly noticed on the forum thread [here](https://forums.swift.org/t/why-is-there-a-collection-flatmap-that-takes-a-closure-returning-string/10141), there is no code that we should be backward compatible with, since `compactMap` has only been introduced recently. After applying this change, the following code is correctly ambiguous again: ```swift [].compactMap { _ in nil } // error: 'nil' requires a contextual type ``` as opposed to: ```swift [].flatMap { _ in nil } // r0 : [String] = [] ``` Fixes: https://bugs.swift.org/browse/SR-7052 (cherry picked from commit 9d70574)
1 parent 3152267 commit b9ed475

File tree

1 file changed

+0
-7
lines changed

1 file changed

+0
-7
lines changed

stdlib/public/core/StringRangeReplaceableCollection.swift.gyb

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -441,13 +441,6 @@ extension Sequence {
441441
}
442442

443443
extension Collection {
444-
@_inlineable // FIXME(sil-serialize-all)
445-
public func compactMap(
446-
_ transform: (Element) throws -> String?
447-
) rethrows -> [String] {
448-
return try _compactMap(transform)
449-
}
450-
451444
@available(swift, deprecated: 4.1, renamed: "compactMap(_:)",
452445
message: "Please use compactMap(_:) for the case where closure returns an optional value")
453446
@inline(__always)

0 commit comments

Comments
 (0)