Skip to content

Commit a43b818

Browse files
Enable the ExistentialAny upcoming language feature
Done with `swift package migrate --to-feature ExistentialAny`.
1 parent f879848 commit a43b818

29 files changed

+83
-82
lines changed

Package.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import PackageDescription
44

55
let commonSwiftSettings: [SwiftSetting] = [
66
.enableUpcomingFeature("MemberImportVisibility"),
7+
.enableUpcomingFeature("ExistentialAny"),
78
]
89

910
let package = Package(

Sources/AblyChat/ChatClient.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public class DefaultChatClient: ChatClient {
6666
_rooms
6767
}
6868

69-
private let logger: InternalLogger
69+
private let logger: any InternalLogger
7070

7171
// (CHA-CS1) Every chat client has a status, which describes the current status of the connection.
7272
// (CHA-CS4) The chat client must allow its connection status to be observed by clients.
@@ -121,7 +121,7 @@ public struct ChatClientOptions: Sendable {
121121
*
122122
* By default, the client will log messages to the console.
123123
*/
124-
public var logHandler: LogHandler?
124+
public var logHandler: (any LogHandler)?
125125

126126
/**
127127
* The minimum log level at which messages will be logged.

Sources/AblyChat/Connection.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public protocol Connection: AnyObject, Sendable {
2525
* - Returns: A subscription that can be used to unsubscribe from ``ConnectionStatusChange`` events.
2626
*/
2727
@discardableResult
28-
func onStatusChange(_ callback: @escaping @MainActor (ConnectionStatusChange) -> Void) -> StatusSubscriptionProtocol
28+
func onStatusChange(_ callback: @escaping @MainActor (ConnectionStatusChange) -> Void) -> any StatusSubscriptionProtocol
2929
}
3030

3131
/// `AsyncSequence` variant of `Connection` status changes.

Sources/AblyChat/DefaultConnection.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ internal final class DefaultConnection: Connection {
2121

2222
// (CHA-CS4d) Clients must be able to register a listener for connection status events and receive such events.
2323
@discardableResult
24-
internal func onStatusChange(_ callback: @escaping @MainActor (ConnectionStatusChange) -> Void) -> StatusSubscriptionProtocol {
24+
internal func onStatusChange(_ callback: @escaping @MainActor (ConnectionStatusChange) -> Void) -> any StatusSubscriptionProtocol {
2525
// (CHA-CS5) The chat client must monitor the underlying realtime connection for connection status changes.
2626
let eventListener = realtime.connection.on { [weak self] stateChange in
2727
guard let self else {

Sources/AblyChat/DefaultMessageReactions.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import Ably
44
internal final class DefaultMessageReactions: MessageReactions {
55
private let channel: any InternalRealtimeChannelProtocol
66
private let roomName: String
7-
private let logger: InternalLogger
7+
private let logger: any InternalLogger
88
private let clientID: String
99
private let chatAPI: ChatAPI
1010
private let options: MessagesOptions
1111

12-
internal init(channel: any InternalRealtimeChannelProtocol, chatAPI: ChatAPI, roomName: String, options: MessagesOptions, clientID: String, logger: InternalLogger) {
12+
internal init(channel: any InternalRealtimeChannelProtocol, chatAPI: ChatAPI, roomName: String, options: MessagesOptions, clientID: String, logger: any InternalLogger) {
1313
self.channel = channel
1414
self.chatAPI = chatAPI
1515
self.roomName = roomName
@@ -60,7 +60,7 @@ internal final class DefaultMessageReactions: MessageReactions {
6060

6161
// (CHA-MR6) Users must be able to subscribe to message reaction summaries via the subscribe method of the MessagesReactions object. The events emitted will be of type MessageReactionSummaryEvent.
6262
@discardableResult
63-
internal func subscribe(_ callback: @escaping @MainActor @Sendable (MessageReactionSummaryEvent) -> Void) -> SubscriptionProtocol {
63+
internal func subscribe(_ callback: @escaping @MainActor @Sendable (MessageReactionSummaryEvent) -> Void) -> any SubscriptionProtocol {
6464
logger.log(message: "Subscribing to message reaction summary events", level: .debug)
6565

6666
let eventListener = channel.subscribe { [weak self] message in
@@ -101,7 +101,7 @@ internal final class DefaultMessageReactions: MessageReactions {
101101

102102
// (CHA-MR7) Users must be able to subscribe to raw message reactions (as individual annotations) via the subscribeRaw method of the MessagesReactions object. The events emitted are of type MessageReactionRawEvent.
103103
@discardableResult
104-
internal func subscribeRaw(_ callback: @escaping @MainActor @Sendable (MessageReactionRawEvent) -> Void) -> SubscriptionProtocol {
104+
internal func subscribeRaw(_ callback: @escaping @MainActor @Sendable (MessageReactionRawEvent) -> Void) -> any SubscriptionProtocol {
105105
logger.log(message: "Subscribing to reaction events", level: .debug)
106106
guard options.rawMessageReactions else {
107107
// (CHA-MR7a) The attempt to subscribe to raw message reactions must throw an ErrorInfo with code 40000 and status code 400 if the room is not configured to support raw message reactions

Sources/AblyChat/DefaultMessages.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ internal final class DefaultMessages: Messages {
88
private let roomName: String
99
private let chatAPI: ChatAPI
1010
private let clientID: String
11-
private let logger: InternalLogger
11+
private let logger: any InternalLogger
1212

1313
private var currentSubscriptionPoint: String?
1414
private var subscriptionPoints: [UUID: String] = [:]
@@ -26,7 +26,7 @@ internal final class DefaultMessages: Messages {
2626
}
2727
}
2828

29-
internal init(channel: any InternalRealtimeChannelProtocol, chatAPI: ChatAPI, roomName: String, options: MessagesOptions = .init(), clientID: String, logger: InternalLogger) {
29+
internal init(channel: any InternalRealtimeChannelProtocol, chatAPI: ChatAPI, roomName: String, options: MessagesOptions = .init(), clientID: String, logger: any InternalLogger) {
3030
self.channel = channel
3131
self.chatAPI = chatAPI
3232
self.roomName = roomName
@@ -36,7 +36,7 @@ internal final class DefaultMessages: Messages {
3636
updateCurrentSubscriptionPoint()
3737
}
3838

39-
internal func subscribe(_ callback: @escaping @MainActor (ChatMessageEvent) -> Void) -> MessageSubscriptionResponseProtocol {
39+
internal func subscribe(_ callback: @escaping @MainActor (ChatMessageEvent) -> Void) -> any MessageSubscriptionResponseProtocol {
4040
logger.log(message: "Subscribing to messages", level: .debug)
4141
// (CHA-M4c) When a realtime message with name set to message.created is received, it is translated into a message event, which contains a type field with the event type as well as a message field containing the Message Struct. This event is then broadcast to all subscribers.
4242
// (CHA-M4d) If a realtime message with an unknown name is received, the SDK shall silently discard the message, though it may log at DEBUG or TRACE level.

Sources/AblyChat/DefaultOccupancy.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ internal final class DefaultOccupancy: Occupancy {
44
private let channel: any InternalRealtimeChannelProtocol
55
private let chatAPI: ChatAPI
66
private let roomName: String
7-
private let logger: InternalLogger
7+
private let logger: any InternalLogger
88
private let options: OccupancyOptions
99

1010
private var lastOccupancyData: OccupancyData?
1111

12-
internal init(channel: any InternalRealtimeChannelProtocol, chatAPI: ChatAPI, roomName: String, logger: InternalLogger, options: OccupancyOptions) {
12+
internal init(channel: any InternalRealtimeChannelProtocol, chatAPI: ChatAPI, roomName: String, logger: any InternalLogger, options: OccupancyOptions) {
1313
self.channel = channel
1414
self.chatAPI = chatAPI
1515
self.roomName = roomName
@@ -18,7 +18,7 @@ internal final class DefaultOccupancy: Occupancy {
1818
}
1919

2020
@discardableResult
21-
internal func subscribe(_ callback: @escaping @MainActor (OccupancyEvent) -> Void) -> SubscriptionProtocol {
21+
internal func subscribe(_ callback: @escaping @MainActor (OccupancyEvent) -> Void) -> any SubscriptionProtocol {
2222
// CHA-O4e (we use a fatalError for this programmer error, which is the idiomatic thing to do for Swift)
2323
guard options.enableEvents else {
2424
fatalError("In order to be able to subscribe to presence events, please set enableEvents to true in the room's occupancy options.")

Sources/AblyChat/DefaultPresence.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ internal final class DefaultPresence: Presence {
55
private let roomLifecycleManager: any RoomLifecycleManager
66
private let roomName: String
77
private let clientID: String
8-
private let logger: InternalLogger
8+
private let logger: any InternalLogger
99
private let options: PresenceOptions
1010

11-
internal init(channel: any InternalRealtimeChannelProtocol, roomLifecycleManager: any RoomLifecycleManager, roomName: String, clientID: String, logger: InternalLogger, options: PresenceOptions) {
11+
internal init(channel: any InternalRealtimeChannelProtocol, roomLifecycleManager: any RoomLifecycleManager, roomName: String, clientID: String, logger: any InternalLogger, options: PresenceOptions) {
1212
self.channel = channel
1313
self.roomLifecycleManager = roomLifecycleManager
1414
self.roomName = roomName
@@ -199,7 +199,7 @@ internal final class DefaultPresence: Presence {
199199

200200
// (CHA-PR7a) Users may provide a listener to subscribe to all presence events in a room.
201201
// (CHA-PR7b) Users may provide a listener and a list of selected presence events, to subscribe to just those events in a room.
202-
internal func subscribe(event: PresenceEventType, _ callback: @escaping @MainActor (PresenceEvent) -> Void) -> SubscriptionProtocol {
202+
internal func subscribe(event: PresenceEventType, _ callback: @escaping @MainActor (PresenceEvent) -> Void) -> any SubscriptionProtocol {
203203
fatalErrorIfEnableEventsDisabled()
204204

205205
logger.log(message: "Subscribing to presence events", level: .debug)
@@ -221,7 +221,7 @@ internal final class DefaultPresence: Presence {
221221
}
222222
}
223223

224-
internal func subscribe(events: [PresenceEventType], _ callback: @escaping @MainActor (PresenceEvent) -> Void) -> SubscriptionProtocol {
224+
internal func subscribe(events: [PresenceEventType], _ callback: @escaping @MainActor (PresenceEvent) -> Void) -> any SubscriptionProtocol {
225225
fatalErrorIfEnableEventsDisabled()
226226

227227
logger.log(message: "Subscribing to presence events", level: .debug)

Sources/AblyChat/DefaultRoomReactions.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import Ably
33
internal final class DefaultRoomReactions: RoomReactions {
44
private let channel: any InternalRealtimeChannelProtocol
55
private let roomName: String
6-
private let logger: InternalLogger
6+
private let logger: any InternalLogger
77
private let clientID: String
88

9-
internal init(channel: any InternalRealtimeChannelProtocol, clientID: String, roomName: String, logger: InternalLogger) {
9+
internal init(channel: any InternalRealtimeChannelProtocol, clientID: String, roomName: String, logger: any InternalLogger) {
1010
self.roomName = roomName
1111
self.channel = channel
1212
self.logger = logger
@@ -34,7 +34,7 @@ internal final class DefaultRoomReactions: RoomReactions {
3434
// (CHA-ER4) A user may subscribe to reaction events in Realtime.
3535
// (CHA-ER4a) A user may provide a listener to subscribe to reaction events. This operation must have no side-effects in relation to room or underlying status. When a realtime message with name roomReaction is received, this message is converted into a reaction object and emitted to subscribers.
3636
@discardableResult
37-
internal func subscribe(_ callback: @escaping @MainActor (RoomReactionEvent) -> Void) -> SubscriptionProtocol {
37+
internal func subscribe(_ callback: @escaping @MainActor (RoomReactionEvent) -> Void) -> any SubscriptionProtocol {
3838
logger.log(message: "Subscribing to reaction events", level: .debug)
3939

4040
// (CHA-ER4c) Realtime events with an unknown name shall be silently discarded.

Sources/AblyChat/DefaultTyping.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ internal final class DefaultTyping: Typing {
44
private let channel: any InternalRealtimeChannelProtocol
55
private let roomName: String
66
private let clientID: String
7-
private let logger: InternalLogger
7+
private let logger: any InternalLogger
88
private let heartbeatThrottle: TimeInterval
99

1010
// (CHA-T10a) A grace period shall be set by the client (the grace period on the CHA-T10 heartbeat interval when receiving events). The default value shall be set to 2000ms.
1111
private let gracePeriod: TimeInterval = 2
1212

13-
private let typingTimerManager: TypingTimerManagerProtocol
13+
private let typingTimerManager: any TypingTimerManagerProtocol
1414

1515
// (CHA-T14) Multiple asynchronous calls to keystroke/stop typing must eventually converge to a consistent state.
1616
// (CHA-TM14a) When a call to keystroke or stop is made, it should attempt to acquire a mutex lock.
1717
// (CHA-TM14b) Once the lock is acquired, if another call is made to either function, the second call shall be queued and wait until it can acquire the lock before executing.
1818
// (CHA-TM14b1) During this time, each new subsequent call to either function shall abort the previously queued call. In doing so, there shall only ever be one pending call and while the mutex is held, thus the most recent call shall "win" and execute once the mutex is released.
1919
private let keyboardOperationQueue = TypingOperationQueue<InternalError>()
2020

21-
internal init(channel: any InternalRealtimeChannelProtocol, roomName: String, clientID: String, logger: InternalLogger, heartbeatThrottle: TimeInterval, clock: some ClockProtocol) {
21+
internal init(channel: any InternalRealtimeChannelProtocol, roomName: String, clientID: String, logger: any InternalLogger, heartbeatThrottle: TimeInterval, clock: some ClockProtocol) {
2222
self.roomName = roomName
2323
self.channel = channel
2424
self.clientID = clientID
@@ -35,7 +35,7 @@ internal final class DefaultTyping: Typing {
3535

3636
// (CHA-T6) Users may subscribe to typing events – updates to a set of clientIDs that are typing. This operation, like all subscription operations, has no side-effects in relation to room lifecycle.
3737
@discardableResult
38-
internal func subscribe(_ callback: @escaping @MainActor (TypingSetEvent) -> Void) -> SubscriptionProtocol {
38+
internal func subscribe(_ callback: @escaping @MainActor (TypingSetEvent) -> Void) -> any SubscriptionProtocol {
3939
// (CHA-T6a) Users may provide a listener to subscribe to typing event V2 in a chat room.
4040
let startedEventListener = channel.subscribe(TypingEventType.started.rawValue) { [weak self] message in
4141
guard let self, let messageClientID = message.clientId else {

0 commit comments

Comments
 (0)