Files
swift-mirror/test/stdlib/FlatMapDeprecation.swift
Dmitrii Galimzianov a8b71ea97f Add -print-diagnostic-groups flag
This change adds the `-print-diagnostic-groups` flag as described by SE-0443.
2024-09-11 13:34:42 +02:00

33 lines
1.6 KiB
Swift

// RUN: %target-typecheck-verify-swift -swift-version 4 -print-diagnostic-groups
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 [availability_deprecated]}} 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 [availability_deprecated]}} 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 [availability_deprecated]}} 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 [availability_deprecated]}} 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 [availability_deprecated]}} expected-note {{compactMap}}
}