Skip to content

Commit

Permalink
fix: resolve Swift 6 warnings - shadowing generics
Browse files Browse the repository at this point in the history
**Motivation:**

Currently, project contains quite amount of shadowed generics warnings.
All this warnings will become errors with Swift 6.

**Modifications:**

Each warning occurency is updated to use slightly different type
parameters name.

**Result:**

- Partially addresses apple#1125
  • Loading branch information
Garfeild committed Jul 2, 2024
1 parent 3fda454 commit 30da421
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Sources/DistributedActorsTestKit/TestProbes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ extension ActorTestProbe {
/// Without this it may happen that we asked the probe to watch an actor, and send a message to the actor directly,
/// and our direct message arrives first, before the watch at the destination, causing potentially confusing behavior
/// in some very ordering delicate testing scenarios.
public func forward<Message>(_ message: Message, to target: _ActorRef<Message>, file: String = #filePath, line: UInt = #line) where Message: Codable {
public func forward<M>(_ message: M, to target: _ActorRef<M>, file: String = #filePath, line: UInt = #line) where M: Codable {
self.internalRef.tell(ProbeCommands.forwardCommand(send: { () in target.tell(message, file: file, line: line) }))
}

Expand Down
4 changes: 2 additions & 2 deletions Sources/DistributedCluster/Adapters.swift
Original file line number Diff line number Diff line change
Expand Up @@ -384,15 +384,15 @@ extension SubReceiveAdapter {
return c.result
}

func _resolve<Message>(context: _ResolveContext<Message>) -> _ActorRef<Message> {
func _resolve<M>(context: _ResolveContext<M>) -> _ActorRef<M> {
guard context.selectorSegments.first == nil,
self.id.incarnation == context.id.incarnation
else {
return context.personalDeadLetters
}

switch self.myself {
case let myself as _ActorRef<Message>:
case let myself as _ActorRef<M>:
return myself
default:
return context.personalDeadLetters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ import NIO
/// Not intended for general use.
public final class _LinkedBlockingQueue<A>: @unchecked Sendable {
@usableFromInline
final class Node<A>: @unchecked Sendable {
final class Node<T>: @unchecked Sendable {
@usableFromInline
var item: A?
var item: T?
@usableFromInline
var next: Node<A>?
var next: Node<T>?

@usableFromInline
init(_ item: A?) {
init(_ item: T?) {
self.item = item
}
}
Expand Down
12 changes: 6 additions & 6 deletions Sources/DistributedCluster/_ActorShell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -626,19 +626,19 @@ public final class _ActorShell<Message: Codable>: _ActorContext<Message>, Abstra
}

@discardableResult
override public func _spawnWatch<Message>(
override public func _spawnWatch<M>(
_ naming: _ActorNaming,
of type: Message.Type = Message.self,
of type: M.Type = M.self,
props: _Props = _Props(),
file: String = #filePath, line: UInt = #line,
_ behavior: _Behavior<Message>
) throws -> _ActorRef<Message>
where Message: Codable
_ behavior: _Behavior<M>
) throws -> _ActorRef<M>
where M: Codable
{
self.watch(try self._spawn(naming, props: props, behavior))
}

override public func stop<Message: Codable>(child ref: _ActorRef<Message>) throws {
override public func stop<M: Codable>(child ref: _ActorRef<M>) throws {
try self._stop(child: ref)
}

Expand Down

0 comments on commit 30da421

Please sign in to comment.