Skip to content

Commit d21be93

Browse files
moiseevairspeedswift
authored andcommitted
[stdlib] Removing the deprecated flatMap overload (#9397)
The following code behaves incorrectly due to the presence of this overload. let a: Int = 1 let b: Int? = 2 let c: Int? = nil let result: [Any] = [a, b, c].flatMap { $0 } Fixes: <rdar://problem/31910642>
1 parent 19c604b commit d21be93

File tree

3 files changed

+1
-48
lines changed

3 files changed

+1
-48
lines changed

stdlib/public/core/SequenceAlgorithms.swift.gyb

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -729,13 +729,6 @@ extension Sequence {
729729
}
730730
return result
731731
}
732-
733-
@available(*, deprecated, message: "This call uses implicit promotion to optional. Please use map instead.")
734-
public func flatMap<T>(
735-
_ transform: (${GElement}) throws -> T
736-
) rethrows -> [T] {
737-
return try map(transform)
738-
}
739732
}
740733

741734
extension Sequence {

test/Constraints/closures.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,7 @@ func returnsArray() -> [Int] { return [] }
512512

513513
returnsArray().flatMap { $0 }.flatMap { }
514514
// expected-warning@-1 {{expression of type 'Int' is unused}}
515-
// expected-warning@-2 {{Please use map instead.}}
516-
// expected-warning@-3 {{result of call to 'flatMap' is unused}}
515+
// expected-warning@-2 {{result of call to 'flatMap' is unused}}
517516

518517
// rdar://problem/30271695
519518
_ = ["hi"].flatMap { $0.isEmpty ? nil : $0 }

test/stdlib/FlatMapDiagnostics.swift.gyb

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)