From 58f7cf5a92cf9fdcb0684d29194f37731990fe2d Mon Sep 17 00:00:00 2001 From: Karoy Lorentey Date: Wed, 5 Oct 2022 11:48:54 -0700 Subject: [PATCH] [SortedSet] SortedSet, .Iterator, .Index, .SubSequence, .SubSequence.Iterator: Explicitly conform to Sendable when Element is Sendable --- .../SortedSet/SortedSet+Sendable.swift | 14 ++++++++++++++ .../SortedSet/SortedSet+Sequence.swift | 5 +++++ .../SortedSet/SortedSet+SubSequence.swift | 10 ++++++++++ .../SortedSet/SortedSet.Index.swift | 5 +++++ 4 files changed, 34 insertions(+) create mode 100644 Sources/SortedCollections/SortedSet/SortedSet+Sendable.swift diff --git a/Sources/SortedCollections/SortedSet/SortedSet+Sendable.swift b/Sources/SortedCollections/SortedSet/SortedSet+Sendable.swift new file mode 100644 index 00000000..26d215ea --- /dev/null +++ b/Sources/SortedCollections/SortedSet/SortedSet+Sendable.swift @@ -0,0 +1,14 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift Collections open source project +// +// Copyright (c) 2022 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// +//===----------------------------------------------------------------------===// + +#if swift(>=5.5) +extension SortedSet: @unchecked Sendable where Element: Sendable {} +#endif diff --git a/Sources/SortedCollections/SortedSet/SortedSet+Sequence.swift b/Sources/SortedCollections/SortedSet/SortedSet+Sequence.swift index e9f3bac9..2b75aeac 100644 --- a/Sources/SortedCollections/SortedSet/SortedSet+Sequence.swift +++ b/Sources/SortedCollections/SortedSet/SortedSet+Sequence.swift @@ -49,3 +49,8 @@ extension SortedSet: Sequence { return Iterator(_base: self) } } + +#if swift(>=5.5) +extension SortedSet.Iterator: @unchecked Sendable +where Element: Sendable {} +#endif diff --git a/Sources/SortedCollections/SortedSet/SortedSet+SubSequence.swift b/Sources/SortedCollections/SortedSet/SortedSet+SubSequence.swift index 32995c5b..f7793016 100644 --- a/Sources/SortedCollections/SortedSet/SortedSet+SubSequence.swift +++ b/Sources/SortedCollections/SortedSet/SortedSet+SubSequence.swift @@ -30,6 +30,11 @@ extension SortedSet { } } +#if swift(>=5.5) +extension SortedSet.SubSequence: @unchecked Sendable +where Element: Sendable {} +#endif + extension SortedSet.SubSequence: Sequence { public typealias Element = SortedSet.Element @@ -66,6 +71,11 @@ extension SortedSet.SubSequence: Sequence { } } +#if swift(>=5.5) +extension SortedSet.SubSequence.Iterator: @unchecked Sendable +where Element: Sendable {} +#endif + extension SortedSet.SubSequence: BidirectionalCollection { public typealias Index = SortedSet.Index public typealias SubSequence = Self diff --git a/Sources/SortedCollections/SortedSet/SortedSet.Index.swift b/Sources/SortedCollections/SortedSet/SortedSet.Index.swift index cfc48e8a..1910e0be 100644 --- a/Sources/SortedCollections/SortedSet/SortedSet.Index.swift +++ b/Sources/SortedCollections/SortedSet/SortedSet.Index.swift @@ -34,6 +34,11 @@ extension SortedSet { } } +#if swift(>=5.5) +extension SortedSet.Index: @unchecked Sendable +where Element: Sendable {} +#endif + // MARK: Equatable extension SortedSet.Index: Equatable { @inlinable