From 0b91523a2b0690c96c05055d679ae2193d42f499 Mon Sep 17 00:00:00 2001 From: Max Moiseev Date: Wed, 21 Feb 2018 11:42:36 -0800 Subject: [PATCH] [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 9d705748bbc9fd0b9dc8810767cb7dc7629e4589) (cherry picked from commit b9ed4751935953324ef61ef3f4273de1e0f57429) --- .../public/core/StringRangeReplaceableCollection.swift.gyb | 7 ------- 1 file changed, 7 deletions(-) diff --git a/stdlib/public/core/StringRangeReplaceableCollection.swift.gyb b/stdlib/public/core/StringRangeReplaceableCollection.swift.gyb index a50dc702cdafa..47b728616af7b 100644 --- a/stdlib/public/core/StringRangeReplaceableCollection.swift.gyb +++ b/stdlib/public/core/StringRangeReplaceableCollection.swift.gyb @@ -441,13 +441,6 @@ extension Sequence { } extension Collection { - @_inlineable // FIXME(sil-serialize-all) - public func compactMap( - _ transform: (Element) throws -> String? - ) rethrows -> [String] { - return try _compactMap(transform) - } - @available(swift, deprecated: 4.1, renamed: "compactMap(_:)", message: "Please use compactMap(_:) for the case where closure returns an optional value") @inline(__always)