From c5dbf5f4f5e3500de139f77b6e484a530cc8c949 Mon Sep 17 00:00:00 2001 From: Karoy Lorentey Date: Mon, 9 May 2022 18:06:17 -0700 Subject: [PATCH 1/9] [stdlib] Adopt primary associated types in the stdlib (cherry picked from commit 7a7ebd89707bf9362f7047b030ffc44f5792ad4a) --- stdlib/public/core/BidirectionalCollection.swift | 2 +- stdlib/public/core/Codable.swift | 4 ++-- stdlib/public/core/Collection.swift | 2 +- stdlib/public/core/CompilerProtocols.swift | 2 +- stdlib/public/core/Identifiable.swift | 2 +- stdlib/public/core/Instant.swift | 2 +- stdlib/public/core/LazyCollection.swift | 5 +++-- stdlib/public/core/LazySequence.swift | 10 ++++------ stdlib/public/core/MutableCollection.swift | 2 +- stdlib/public/core/OptionSet.swift | 2 +- stdlib/public/core/RandomAccessCollection.swift | 2 +- stdlib/public/core/Range.swift | 2 +- stdlib/public/core/RangeReplaceableCollection.swift | 4 ++-- stdlib/public/core/SIMDVector.swift | 12 +++++++----- stdlib/public/core/Sequence.swift | 4 ++-- stdlib/public/core/SetAlgebra.swift | 2 +- stdlib/public/core/Stride.swift | 2 +- 17 files changed, 31 insertions(+), 30 deletions(-) diff --git a/stdlib/public/core/BidirectionalCollection.swift b/stdlib/public/core/BidirectionalCollection.swift index 6342bf90ebe7d..61cc712b459f5 100644 --- a/stdlib/public/core/BidirectionalCollection.swift +++ b/stdlib/public/core/BidirectionalCollection.swift @@ -39,7 +39,7 @@ /// Valid indices are exactly those indices that are reachable from the /// collection's `startIndex` by repeated applications of `index(after:)`, up /// to, and including, the `endIndex`. -public protocol BidirectionalCollection: Collection +public protocol BidirectionalCollection: Collection where SubSequence: BidirectionalCollection, Indices: BidirectionalCollection { // FIXME: Only needed for associated type inference. override associatedtype Element diff --git a/stdlib/public/core/Codable.swift b/stdlib/public/core/Codable.swift index ddec94f6a5f0a..a3ad51f7273c6 100644 --- a/stdlib/public/core/Codable.swift +++ b/stdlib/public/core/Codable.swift @@ -183,7 +183,7 @@ public protocol Decoder { /// /// Encoders should provide types conforming to /// `KeyedEncodingContainerProtocol` for their format. -public protocol KeyedEncodingContainerProtocol { +public protocol KeyedEncodingContainerProtocol { associatedtype Key: CodingKey /// The path of coding keys taken to get to this point in encoding. @@ -938,7 +938,7 @@ public struct KeyedEncodingContainer : /// /// Decoders should provide types conforming to `UnkeyedDecodingContainer` for /// their format. -public protocol KeyedDecodingContainerProtocol { +public protocol KeyedDecodingContainerProtocol { associatedtype Key: CodingKey /// The path of coding keys taken to get to this point in decoding. diff --git a/stdlib/public/core/Collection.swift b/stdlib/public/core/Collection.swift index eda2c94440101..dce77ab73990d 100644 --- a/stdlib/public/core/Collection.swift +++ b/stdlib/public/core/Collection.swift @@ -335,7 +335,7 @@ extension IndexingIterator: Sendable /// or bidirectional collection must traverse the entire collection to count /// the number of contained elements, accessing its `count` property is an /// O(*n*) operation. -public protocol Collection: Sequence { +public protocol Collection: Sequence { // FIXME: ideally this would be in MigrationSupport.swift, but it needs // to be on the protocol instead of as an extension @available(*, deprecated/*, obsoleted: 5.0*/, message: "all index distances are now of type Int") diff --git a/stdlib/public/core/CompilerProtocols.swift b/stdlib/public/core/CompilerProtocols.swift index a3f72b547fad3..b749b791191a1 100644 --- a/stdlib/public/core/CompilerProtocols.swift +++ b/stdlib/public/core/CompilerProtocols.swift @@ -98,7 +98,7 @@ /// // Prints "false" /// print(allowedMoves.rawValue & Directions.right.rawValue) /// // Prints "0" -public protocol RawRepresentable { +public protocol RawRepresentable { /// The raw type that can be used to represent all values of the conforming /// type. /// diff --git a/stdlib/public/core/Identifiable.swift b/stdlib/public/core/Identifiable.swift index 876007a62521f..731801700b99e 100644 --- a/stdlib/public/core/Identifiable.swift +++ b/stdlib/public/core/Identifiable.swift @@ -39,7 +39,7 @@ /// lifetime of an object. If an object has a stronger notion of identity, it /// may be appropriate to provide a custom implementation. @available(SwiftStdlib 5.1, *) -public protocol Identifiable { +public protocol Identifiable { /// A type representing the stable identity of the entity associated with /// an instance. diff --git a/stdlib/public/core/Instant.swift b/stdlib/public/core/Instant.swift index dc0955d5e5fb0..baec28e430320 100644 --- a/stdlib/public/core/Instant.swift +++ b/stdlib/public/core/Instant.swift @@ -12,7 +12,7 @@ // A type that defines a specific point in time for a given `Clock`. @available(SwiftStdlib 5.7, *) -public protocol InstantProtocol: Comparable, Hashable, Sendable { +public protocol InstantProtocol: Comparable, Hashable, Sendable { associatedtype Duration: DurationProtocol func advanced(by duration: Duration) -> Self func duration(to other: Self) -> Duration diff --git a/stdlib/public/core/LazyCollection.swift b/stdlib/public/core/LazyCollection.swift index c84027f34614d..348e58afd0e77 100644 --- a/stdlib/public/core/LazyCollection.swift +++ b/stdlib/public/core/LazyCollection.swift @@ -10,8 +10,9 @@ // //===----------------------------------------------------------------------===// -public protocol LazyCollectionProtocol: Collection, LazySequenceProtocol -where Elements: Collection { } +public protocol LazyCollectionProtocol +: Collection, LazySequenceProtocol +where Elements: Collection {} extension LazyCollectionProtocol { // Lazy things are already lazy diff --git a/stdlib/public/core/LazySequence.swift b/stdlib/public/core/LazySequence.swift index 43ade83501548..1f00b63e749f1 100644 --- a/stdlib/public/core/LazySequence.swift +++ b/stdlib/public/core/LazySequence.swift @@ -128,7 +128,8 @@ /// and discards the resulting array. Instead, use `reduce` for summing /// operations, or `forEach` or a `for`-`in` loop for operations with side /// effects. -public protocol LazySequenceProtocol: Sequence { +public protocol LazySequenceProtocol: Sequence +where Elements.Element == Element { /// A `Sequence` that can contain the same elements as this one, /// possibly with a simpler type. /// @@ -138,11 +139,8 @@ public protocol LazySequenceProtocol: Sequence { /// A sequence containing the same elements as this one, possibly with /// a simpler type. /// - /// When implementing lazy operations, wrapping `elements` instead - /// of `self` can prevent result types from growing an extra - /// `LazySequence` layer. For example, - /// - /// _prext_ example needed + /// When implementing lazy operations, wrapping `elements` instead of `self` + /// can prevent result types from growing an extra `LazySequence` layer. /// /// Note: this property need not be implemented by conforming types, /// it has a default implementation in a protocol extension that diff --git a/stdlib/public/core/MutableCollection.swift b/stdlib/public/core/MutableCollection.swift index 2c13da536495f..5b0657799a109 100644 --- a/stdlib/public/core/MutableCollection.swift +++ b/stdlib/public/core/MutableCollection.swift @@ -57,7 +57,7 @@ /// // Must be equivalent to: /// a[i] = x /// let y = x -public protocol MutableCollection: Collection +public protocol MutableCollection: Collection where SubSequence: MutableCollection { // FIXME: Associated type inference requires these. diff --git a/stdlib/public/core/OptionSet.swift b/stdlib/public/core/OptionSet.swift index 427a33d960edc..53865d62c29fb 100644 --- a/stdlib/public/core/OptionSet.swift +++ b/stdlib/public/core/OptionSet.swift @@ -83,7 +83,7 @@ /// print("Add more to your cart for free priority shipping!") /// } /// // Prints "You've earned free priority shipping!" -public protocol OptionSet: SetAlgebra, RawRepresentable { +public protocol OptionSet: SetAlgebra, RawRepresentable { // We can't constrain the associated Element type to be the same as // Self, but we can do almost as well with a default and a // constrained extension diff --git a/stdlib/public/core/RandomAccessCollection.swift b/stdlib/public/core/RandomAccessCollection.swift index ced1d9d749b50..0ac96e36d1767 100644 --- a/stdlib/public/core/RandomAccessCollection.swift +++ b/stdlib/public/core/RandomAccessCollection.swift @@ -30,7 +30,7 @@ /// collection, either the index for your custom type must conform to the /// `Strideable` protocol or you must implement the `index(_:offsetBy:)` and /// `distance(from:to:)` methods with O(1) efficiency. -public protocol RandomAccessCollection: BidirectionalCollection +public protocol RandomAccessCollection: BidirectionalCollection where SubSequence: RandomAccessCollection, Indices: RandomAccessCollection { // FIXME: Associated type inference requires these. diff --git a/stdlib/public/core/Range.swift b/stdlib/public/core/Range.swift index 094d33c3fc416..dd368177f61b1 100644 --- a/stdlib/public/core/Range.swift +++ b/stdlib/public/core/Range.swift @@ -14,7 +14,7 @@ /// /// A type that conforms to `RangeExpression` can convert itself to a /// `Range` of indices within a given collection. -public protocol RangeExpression { +public protocol RangeExpression { /// The type for which the expression describes a range. associatedtype Bound: Comparable diff --git a/stdlib/public/core/RangeReplaceableCollection.swift b/stdlib/public/core/RangeReplaceableCollection.swift index b09244b1bf8e2..8e592f7082617 100644 --- a/stdlib/public/core/RangeReplaceableCollection.swift +++ b/stdlib/public/core/RangeReplaceableCollection.swift @@ -61,8 +61,8 @@ /// `replaceSubrange(_:with:)` with an empty collection for the `newElements` /// parameter. You can override any of the protocol's required methods to /// provide your own custom implementation. -public protocol RangeReplaceableCollection: Collection - where SubSequence: RangeReplaceableCollection { +public protocol RangeReplaceableCollection: Collection +where SubSequence: RangeReplaceableCollection { // FIXME: Associated type inference requires this. override associatedtype SubSequence diff --git a/stdlib/public/core/SIMDVector.swift b/stdlib/public/core/SIMDVector.swift index 951b699faf255..7e0522a3cb296 100644 --- a/stdlib/public/core/SIMDVector.swift +++ b/stdlib/public/core/SIMDVector.swift @@ -72,11 +72,13 @@ public protocol SIMDScalar { } /// A SIMD vector of a fixed number of elements. -public protocol SIMD: SIMDStorage, - Codable, - Hashable, - CustomStringConvertible, - ExpressibleByArrayLiteral { +public protocol SIMD: + SIMDStorage, + Codable, + Hashable, + CustomStringConvertible, + ExpressibleByArrayLiteral +{ /// The mask type resulting from pointwise comparisons of this vector type. associatedtype MaskStorage: SIMD where MaskStorage.Scalar: FixedWidthInteger & SignedInteger diff --git a/stdlib/public/core/Sequence.swift b/stdlib/public/core/Sequence.swift index 3df5231d0a5ef..35305ea79bdef 100644 --- a/stdlib/public/core/Sequence.swift +++ b/stdlib/public/core/Sequence.swift @@ -174,7 +174,7 @@ /// // Prints "3..." /// // Prints "2..." /// // Prints "1..." -public protocol IteratorProtocol { +public protocol IteratorProtocol { /// The type of element traversed by the iterator. associatedtype Element @@ -322,7 +322,7 @@ public protocol IteratorProtocol { /// makes no other requirements about element access, so routines that /// traverse a sequence should be considered O(*n*) unless documented /// otherwise. -public protocol Sequence { +public protocol Sequence { /// A type representing the sequence's elements. associatedtype Element diff --git a/stdlib/public/core/SetAlgebra.swift b/stdlib/public/core/SetAlgebra.swift index a7c206af3213f..e9cf5a92290a7 100644 --- a/stdlib/public/core/SetAlgebra.swift +++ b/stdlib/public/core/SetAlgebra.swift @@ -52,7 +52,7 @@ /// - `x.isStrictSuperset(of: y)` if and only if /// `x.isSuperset(of: y) && x != y` /// - `x.isStrictSubset(of: y)` if and only if `x.isSubset(of: y) && x != y` -public protocol SetAlgebra: Equatable, ExpressibleByArrayLiteral { +public protocol SetAlgebra: Equatable, ExpressibleByArrayLiteral { /// A type for which the conforming type provides a containment test. associatedtype Element diff --git a/stdlib/public/core/Stride.swift b/stdlib/public/core/Stride.swift index 8d20c613f9825..f269d3eca9552 100644 --- a/stdlib/public/core/Stride.swift +++ b/stdlib/public/core/Stride.swift @@ -96,7 +96,7 @@ /// `Stride` type's implementations. If a type conforming to `Strideable` is /// its own `Stride` type, it must provide concrete implementations of the /// two operators to avoid infinite recursion. -public protocol Strideable: Comparable { +public protocol Strideable: Comparable { /// A type that represents the distance between two values. associatedtype Stride: SignedNumeric, Comparable From 6afbfed2c1a938b81469aa220cbb1fcdcbd5dd5f Mon Sep 17 00:00:00 2001 From: Karoy Lorentey Date: Mon, 9 May 2022 18:07:09 -0700 Subject: [PATCH 2/9] [stdlib] Adopt primary associated types in _Concurrency (cherry picked from commit 6d09bb0613ef190e945254166fc14fb90cf5b5ad) --- stdlib/public/Concurrency/Clock.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/public/Concurrency/Clock.swift b/stdlib/public/Concurrency/Clock.swift index e05ca3c4e5a3c..ad3ed884fd222 100644 --- a/stdlib/public/Concurrency/Clock.swift +++ b/stdlib/public/Concurrency/Clock.swift @@ -31,7 +31,7 @@ import Swift /// For more information about specific clocks see `ContinuousClock` and /// `SuspendingClock`. @available(SwiftStdlib 5.7, *) -public protocol Clock: Sendable { +public protocol Clock: Sendable { associatedtype Duration associatedtype Instant: InstantProtocol where Instant.Duration == Duration From b92ecf27c39150720f27ea36161868cde63c12df Mon Sep 17 00:00:00 2001 From: Karoy Lorentey Date: Fri, 1 Apr 2022 17:20:04 -0700 Subject: [PATCH 3/9] =?UTF-8?q?[stdlib]=20Don=E2=80=99t=20mark=20Key=20as?= =?UTF-8?q?=20primary=20on=20Keyed*ContainerProtocol?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 191eaaddfd6b232c2eb53d4321f319ed158da1cd) --- stdlib/public/core/Codable.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/public/core/Codable.swift b/stdlib/public/core/Codable.swift index a3ad51f7273c6..7d4ab8adc8ddb 100644 --- a/stdlib/public/core/Codable.swift +++ b/stdlib/public/core/Codable.swift @@ -183,7 +183,7 @@ public protocol Decoder { /// /// Encoders should provide types conforming to /// `KeyedEncodingContainerProtocol` for their format. -public protocol KeyedEncodingContainerProtocol { +public protocol KeyedEncodingContainerProtocol { associatedtype Key: CodingKey /// The path of coding keys taken to get to this point in encoding. From 58f77f2226c75270cc93a0735f588cb995a2c81c Mon Sep 17 00:00:00 2001 From: Karoy Lorentey Date: Sat, 2 Apr 2022 00:13:06 -0700 Subject: [PATCH 4/9] Update stdlib/public/core/Codable.swift Co-authored-by: Ben Rimmington (cherry picked from commit 9f177d1243a4907f22133f374472ed044543b4f3) --- stdlib/public/core/Codable.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/public/core/Codable.swift b/stdlib/public/core/Codable.swift index 7d4ab8adc8ddb..ddec94f6a5f0a 100644 --- a/stdlib/public/core/Codable.swift +++ b/stdlib/public/core/Codable.swift @@ -938,7 +938,7 @@ public struct KeyedEncodingContainer : /// /// Decoders should provide types conforming to `UnkeyedDecodingContainer` for /// their format. -public protocol KeyedDecodingContainerProtocol { +public protocol KeyedDecodingContainerProtocol { associatedtype Key: CodingKey /// The path of coding keys taken to get to this point in decoding. From c5a5a33e313b2824b59681fe92aac5b58c5b9599 Mon Sep 17 00:00:00 2001 From: Karoy Lorentey Date: Mon, 4 Apr 2022 17:18:14 -0700 Subject: [PATCH 5/9] [stdlib] LazySequenceProtocol: Take out duplicate where clause (cherry picked from commit 655f085c87b4ffef1674c2b85f13ea48a97903a4) --- stdlib/public/core/LazySequence.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/stdlib/public/core/LazySequence.swift b/stdlib/public/core/LazySequence.swift index 1f00b63e749f1..199636344af0d 100644 --- a/stdlib/public/core/LazySequence.swift +++ b/stdlib/public/core/LazySequence.swift @@ -128,8 +128,7 @@ /// and discards the resulting array. Instead, use `reduce` for summing /// operations, or `forEach` or a `for`-`in` loop for operations with side /// effects. -public protocol LazySequenceProtocol: Sequence -where Elements.Element == Element { +public protocol LazySequenceProtocol: Sequence { /// A `Sequence` that can contain the same elements as this one, /// possibly with a simpler type. /// From a2aab8dfa70b0d9d5e757d081c03db67afb9210f Mon Sep 17 00:00:00 2001 From: Karoy Lorentey Date: Mon, 9 May 2022 18:09:21 -0700 Subject: [PATCH 6/9] [stdlib] Take out primary associated types on LazySequenceProtocol/LazyCollectionProtocol for now (cherry picked from commit 063c8456a1b96aebbb83173d02a4f14ad230e4f1) --- stdlib/public/core/LazyCollection.swift | 3 +-- stdlib/public/core/LazySequence.swift | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/stdlib/public/core/LazyCollection.swift b/stdlib/public/core/LazyCollection.swift index 348e58afd0e77..7eb0d53d4b4b9 100644 --- a/stdlib/public/core/LazyCollection.swift +++ b/stdlib/public/core/LazyCollection.swift @@ -10,8 +10,7 @@ // //===----------------------------------------------------------------------===// -public protocol LazyCollectionProtocol -: Collection, LazySequenceProtocol +public protocol LazyCollectionProtocol: Collection, LazySequenceProtocol where Elements: Collection {} extension LazyCollectionProtocol { diff --git a/stdlib/public/core/LazySequence.swift b/stdlib/public/core/LazySequence.swift index 199636344af0d..e0d25d3b92357 100644 --- a/stdlib/public/core/LazySequence.swift +++ b/stdlib/public/core/LazySequence.swift @@ -128,7 +128,7 @@ /// and discards the resulting array. Instead, use `reduce` for summing /// operations, or `forEach` or a `for`-`in` loop for operations with side /// effects. -public protocol LazySequenceProtocol: Sequence { +public protocol LazySequenceProtocol: Sequence { /// A `Sequence` that can contain the same elements as this one, /// possibly with a simpler type. /// From 924a8c6568d37c6da90cc3cc3c35c0c3a7276af1 Mon Sep 17 00:00:00 2001 From: Karoy Lorentey Date: Mon, 9 May 2022 18:12:23 -0700 Subject: [PATCH 7/9] [stdlib][Distributed] Add primary associated types for distributed actor protocols (cherry picked from commit eed5bd131a6deccf3827319532e11a5b0e9e034f) --- stdlib/public/Distributed/DistributedActor.swift | 2 +- stdlib/public/Distributed/DistributedActorSystem.swift | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/stdlib/public/Distributed/DistributedActor.swift b/stdlib/public/Distributed/DistributedActor.swift index 86a6f207e31cf..f53b6a5665779 100644 --- a/stdlib/public/Distributed/DistributedActor.swift +++ b/stdlib/public/Distributed/DistributedActor.swift @@ -41,7 +41,7 @@ import _Concurrency /// Use the `CodingUserInfoKey.actorSystemKey` to provide the necessary /// actor system for the decoding initializer when decoding a distributed actor. @available(SwiftStdlib 5.7, *) -public protocol DistributedActor: AnyActor, Identifiable, Hashable +public protocol DistributedActor: AnyActor, Identifiable, Hashable where ID == ActorSystem.ActorID, SerializationRequirement == ActorSystem.SerializationRequirement { diff --git a/stdlib/public/Distributed/DistributedActorSystem.swift b/stdlib/public/Distributed/DistributedActorSystem.swift index d70301cbd32f1..2c9be75363d76 100644 --- a/stdlib/public/Distributed/DistributedActorSystem.swift +++ b/stdlib/public/Distributed/DistributedActorSystem.swift @@ -14,7 +14,7 @@ import _Concurrency /// A distributed actor system @available(SwiftStdlib 5.7, *) -public protocol DistributedActorSystem: Sendable { +public protocol DistributedActorSystem: Sendable { /// The identity used by actors that communicate via this transport associatedtype ActorID: Sendable & Hashable @@ -445,7 +445,7 @@ func _executeDistributedTarget( /// so decoding can rely on simply invoking e.g. `Codable` (if that is the `SerializationRequirement`) decoding /// entry points on the provided types. @available(SwiftStdlib 5.7, *) -public protocol DistributedTargetInvocationEncoder { +public protocol DistributedTargetInvocationEncoder { associatedtype SerializationRequirement /// The arguments must be encoded order-preserving, and once `decodeGenericSubstitutions` @@ -518,7 +518,7 @@ public struct RemoteCallArgument { /// Decoder that must be provided to `executeDistributedTarget` and is used /// by the Swift runtime to decode arguments of the invocation. @available(SwiftStdlib 5.7, *) -public protocol DistributedTargetInvocationDecoder { +public protocol DistributedTargetInvocationDecoder { associatedtype SerializationRequirement mutating func decodeGenericSubstitutions() throws -> [Any.Type] @@ -548,7 +548,9 @@ public protocol DistributedTargetInvocationDecoder { } @available(SwiftStdlib 5.7, *) -public protocol DistributedTargetInvocationResultHandler { +public protocol DistributedTargetInvocationResultHandler< + SerializationRequirement +> { associatedtype SerializationRequirement // func onReturn(value: Success) async throws From 6bf17a742c6e39e2e511205757747e0b8c24c4d5 Mon Sep 17 00:00:00 2001 From: Karoy Lorentey Date: Mon, 9 May 2022 20:20:26 -0700 Subject: [PATCH 8/9] Revert "[stdlib][Distributed] Add primary associated types for distributed actor protocols" This reverts commit eed5bd131a6deccf3827319532e11a5b0e9e034f. (cherry picked from commit 1df918e92433c2d6b91e9994dafb87bed74e45f6) --- stdlib/public/Distributed/DistributedActor.swift | 2 +- stdlib/public/Distributed/DistributedActorSystem.swift | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/stdlib/public/Distributed/DistributedActor.swift b/stdlib/public/Distributed/DistributedActor.swift index f53b6a5665779..86a6f207e31cf 100644 --- a/stdlib/public/Distributed/DistributedActor.swift +++ b/stdlib/public/Distributed/DistributedActor.swift @@ -41,7 +41,7 @@ import _Concurrency /// Use the `CodingUserInfoKey.actorSystemKey` to provide the necessary /// actor system for the decoding initializer when decoding a distributed actor. @available(SwiftStdlib 5.7, *) -public protocol DistributedActor: AnyActor, Identifiable, Hashable +public protocol DistributedActor: AnyActor, Identifiable, Hashable where ID == ActorSystem.ActorID, SerializationRequirement == ActorSystem.SerializationRequirement { diff --git a/stdlib/public/Distributed/DistributedActorSystem.swift b/stdlib/public/Distributed/DistributedActorSystem.swift index 2c9be75363d76..d70301cbd32f1 100644 --- a/stdlib/public/Distributed/DistributedActorSystem.swift +++ b/stdlib/public/Distributed/DistributedActorSystem.swift @@ -14,7 +14,7 @@ import _Concurrency /// A distributed actor system @available(SwiftStdlib 5.7, *) -public protocol DistributedActorSystem: Sendable { +public protocol DistributedActorSystem: Sendable { /// The identity used by actors that communicate via this transport associatedtype ActorID: Sendable & Hashable @@ -445,7 +445,7 @@ func _executeDistributedTarget( /// so decoding can rely on simply invoking e.g. `Codable` (if that is the `SerializationRequirement`) decoding /// entry points on the provided types. @available(SwiftStdlib 5.7, *) -public protocol DistributedTargetInvocationEncoder { +public protocol DistributedTargetInvocationEncoder { associatedtype SerializationRequirement /// The arguments must be encoded order-preserving, and once `decodeGenericSubstitutions` @@ -518,7 +518,7 @@ public struct RemoteCallArgument { /// Decoder that must be provided to `executeDistributedTarget` and is used /// by the Swift runtime to decode arguments of the invocation. @available(SwiftStdlib 5.7, *) -public protocol DistributedTargetInvocationDecoder { +public protocol DistributedTargetInvocationDecoder { associatedtype SerializationRequirement mutating func decodeGenericSubstitutions() throws -> [Any.Type] @@ -548,9 +548,7 @@ public protocol DistributedTargetInvocationDecoder { } @available(SwiftStdlib 5.7, *) -public protocol DistributedTargetInvocationResultHandler< - SerializationRequirement -> { +public protocol DistributedTargetInvocationResultHandler { associatedtype SerializationRequirement // func onReturn(value: Success) async throws From 6efa6a147243d03f2a402ee2faf718f6b673c275 Mon Sep 17 00:00:00 2001 From: Karoy Lorentey Date: Wed, 22 Jun 2022 17:22:18 -0700 Subject: [PATCH 9/9] [stdlib] OptionSet: Remove the primary associated type declaration `Element` is expected to always be `Self`. `RawValue` would be a better choice for the primary type ("option set of UInt32"), but to avoid confusion, it seems better to just omit the declaration, at least for now. (cherry picked from commit 2759a710e6c52508340d7b4cc71b5ff05704e6ae) --- stdlib/public/core/OptionSet.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/public/core/OptionSet.swift b/stdlib/public/core/OptionSet.swift index 53865d62c29fb..427a33d960edc 100644 --- a/stdlib/public/core/OptionSet.swift +++ b/stdlib/public/core/OptionSet.swift @@ -83,7 +83,7 @@ /// print("Add more to your cart for free priority shipping!") /// } /// // Prints "You've earned free priority shipping!" -public protocol OptionSet: SetAlgebra, RawRepresentable { +public protocol OptionSet: SetAlgebra, RawRepresentable { // We can't constrain the associated Element type to be the same as // Self, but we can do almost as well with a default and a // constrained extension