Files
swift-mirror/test/stdlib/FlatMapDeprecation.swift
Doug Gregor b182c96bd7 Print diagnostic group names by default
Print diagnostic groups as part of the LLVM printer in the same manner as the
Swift one does, always. Make `-print-diagnostic-groups` an inert option, since we
always print diagnostic group names with the `[#GroupName]` syntax.

As part of this, we no longer render the diagnostic group name as part
of the diagnostic *text*, instead leaving it up to the diagnostic
renderer to handle the category appropriately. Update all of the tests
that were depending on `-print-diagnostic-groups` putting it into the
text to instead use the `{{documentation-file=<file name>}}`
diagnostic verification syntax.
2025-03-29 15:40:56 -07:00

33 lines
1.7 KiB
Swift

// RUN: %target-typecheck-verify-swift -swift-version 4
func flatMapOnSequence<
S : Sequence
>(xs: S, f: (S.Element) -> S.Element?) {
_ = xs.flatMap(f) // expected-warning {{'flatMap' is deprecated: Please use compactMap(_:) for the case where closure returns an optional value}}{{documentation-file=deprecated-declaration}} expected-note {{compactMap}}
}
func flatMapOnLazySequence<
S : LazySequenceProtocol
>(xs: S, f: (S.Element) -> S.Element?) {
_ = xs.flatMap(f) // expected-warning {{'flatMap' is deprecated: Please use compactMap(_:) for the case where closure returns an optional value}}{{documentation-file=deprecated-declaration}} expected-note {{compactMap}}
}
func flatMapOnLazyCollection<
C : LazyCollectionProtocol
>(xs: C, f: (C.Element) -> C.Element?) {
_ = xs.flatMap(f) // expected-warning {{'flatMap' is deprecated: Please use compactMap(_:) for the case where closure returns an optional value}}{{documentation-file=deprecated-declaration}} expected-note {{compactMap}}
}
func flatMapOnLazyBidirectionalCollection<
C : LazyCollectionProtocol & BidirectionalCollection
>(xs: C, f: (C.Element) -> C.Element?)
where C.Elements : BidirectionalCollection {
_ = xs.flatMap(f) // expected-warning {{'flatMap' is deprecated: Please use compactMap(_:) for the case where closure returns an optional value}}{{documentation-file=deprecated-declaration}} expected-note {{compactMap}}
}
func flatMapOnCollectionOfStrings<
C : Collection
>(xs: C, f: (C.Element) -> String?) {
_ = xs.flatMap(f) // expected-warning {{'flatMap' is deprecated: Please use compactMap(_:) for the case where closure returns an optional value}}{{documentation-file=deprecated-declaration}} expected-note {{compactMap}}
}