Skip to content

Commit 88b66a8

Browse files
authored
Use #filePath instead of #file (#984)
Resolves #635
1 parent 5231975 commit 88b66a8

39 files changed

+209
-209
lines changed

Sources/DistributedActors/ActorContext.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,15 @@ public class _ActorContext<Message: Codable> /* TODO(sendable): NOTSendable*/ {
102102
public func watch<Watchee>(
103103
_ watchee: Watchee,
104104
with terminationMessage: Message? = nil,
105-
file: String = #file, line: UInt = #line
105+
file: String = #filePath, line: UInt = #line
106106
) -> Watchee where Watchee: _DeathWatchable {
107107
_undefined()
108108
}
109109

110110
@discardableResult
111111
public func unwatch<Watchee>(
112112
_ watchee: Watchee,
113-
file: String = #file, line: UInt = #line
113+
file: String = #filePath, line: UInt = #line
114114
) -> Watchee where Watchee: _DeathWatchable {
115115
_undefined()
116116
}
@@ -123,7 +123,7 @@ public class _ActorContext<Message: Codable> /* TODO(sendable): NOTSendable*/ {
123123
_ naming: _ActorNaming,
124124
of type: M.Type = M.self,
125125
props: _Props = _Props(),
126-
file: String = #file, line: UInt = #line,
126+
file: String = #filePath, line: UInt = #line,
127127
_ behavior: _Behavior<M>
128128
) throws -> _ActorRef<M>
129129
where M: Codable
@@ -142,7 +142,7 @@ public class _ActorContext<Message: Codable> /* TODO(sendable): NOTSendable*/ {
142142
_ naming: _ActorNaming,
143143
of type: M.Type = M.self,
144144
props: _Props = _Props(),
145-
file: String = #file, line: UInt = #line,
145+
file: String = #filePath, line: UInt = #line,
146146
_ behavior: _Behavior<M>
147147
) throws -> _ActorRef<M>
148148
where M: Codable
@@ -192,7 +192,7 @@ public class _ActorContext<Message: Codable> /* TODO(sendable): NOTSendable*/ {
192192
/// - Parameter callback: the closure that should be executed in this actor's context
193193
/// - Returns: an `AsynchronousCallback` that is safe to call from outside of this actor
194194
@usableFromInline
195-
internal func makeAsynchronousCallback<T>(file: String = #file, line: UInt = #line, _ callback: @escaping (T) throws -> Void) -> AsynchronousCallback<T> {
195+
internal func makeAsynchronousCallback<T>(file: String = #filePath, line: UInt = #line, _ callback: @escaping (T) throws -> Void) -> AsynchronousCallback<T> {
196196
AsynchronousCallback(callback: callback) { [weak selfRef = self.myself._unsafeUnwrapCell] in
197197
selfRef?.sendClosure(file: file, line: line, $0)
198198
}
@@ -209,7 +209,7 @@ public class _ActorContext<Message: Codable> /* TODO(sendable): NOTSendable*/ {
209209
/// - Parameter callback: the closure that should be executed in this actor's context
210210
/// - Returns: an `AsynchronousCallback` that is safe to call from outside of this actor
211211
@usableFromInline
212-
internal func makeAsynchronousCallback<T>(for type: T.Type, file: String = #file, line: UInt = #line, callback: @escaping (T) throws -> Void) -> AsynchronousCallback<T> {
212+
internal func makeAsynchronousCallback<T>(for type: T.Type, file: String = #filePath, line: UInt = #line, callback: @escaping (T) throws -> Void) -> AsynchronousCallback<T> {
213213
AsynchronousCallback(callback: callback) { [weak selfRef = self.myself._unsafeUnwrapCell] in
214214
selfRef?.sendClosure(file: file, line: line, $0)
215215
}
@@ -280,7 +280,7 @@ public class _ActorContext<Message: Codable> /* TODO(sendable): NOTSendable*/ {
280280
/// - timeout: time after which the _AsyncResult will be failed if it does not complete
281281
/// - continuation: continuation to run after `_AsyncResult` completes.
282282
/// It is safe to access and modify actor state from here.
283-
internal func onResultAsync<AR: _AsyncResult>(of _AsyncResult: AR, timeout: Duration, file: String = #file, line: UInt = #line, _ continuation: @escaping (Result<AR.Value, Error>) throws -> _Behavior<Message>) {
283+
internal func onResultAsync<AR: _AsyncResult>(of _AsyncResult: AR, timeout: Duration, file: String = #filePath, line: UInt = #line, _ continuation: @escaping (Result<AR.Value, Error>) throws -> _Behavior<Message>) {
284284
let asyncCallback = self.makeAsynchronousCallback(for: Result<AR.Value, Error>.self, file: file, line: line) {
285285
let nextBehavior = try continuation($0)
286286
let shell = self._downcastUnsafe

Sources/DistributedActors/ActorLogging.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ extension Logger {
357357
level: Logger.Level?,
358358
_ message: @autoclosure () -> Logger.Message,
359359
metadata: @autoclosure () -> Logger.Metadata? = nil,
360-
file: String = #file, function: String = #function, line: UInt = #line
360+
file: String = #filePath, function: String = #function, line: UInt = #line
361361
) {
362362
if let level = level {
363363
self.log(level: level, message(), metadata: metadata(), file: file, function: function, line: line)

Sources/DistributedActors/ActorRef+Ask.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ extension _ActorRef: ReceivesQuestions {
6767
func ask<Answer>(
6868
for answerType: Answer.Type = Answer.self,
6969
timeout: Duration,
70-
file: String = #file, function: String = #function, line: UInt = #line,
70+
file: String = #filePath, function: String = #function, line: UInt = #line,
7171
_ makeQuestion: @escaping (_ActorRef<Answer>) -> Question
7272
) -> AskResponse<Answer> {
7373
guard let system = self._system else {

Sources/DistributedActors/ActorShell+Children.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift Distributed Actors open source project
44
//
5-
// Copyright (c) 2018-2019 Apple Inc. and the Swift Distributed Actors project authors
5+
// Copyright (c) 2018-2022 Apple Inc. and the Swift Distributed Actors project authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
@@ -293,7 +293,7 @@ extension _Children {
293293
let childOpt = self.container[name]
294294
switch childOpt {
295295
case .some(.cell(let cell)) where self._markAsStoppingChild(identifiedBy: cell.receivesSystemMessages.id):
296-
cell.receivesSystemMessages._sendSystemMessage(.stop, file: #file, line: #line)
296+
cell.receivesSystemMessages._sendSystemMessage(.stop, file: #filePath, line: #line)
297297
return true
298298
case .some(.adapter(let ref)) where includeAdapters:
299299
ref.stop()

Sources/DistributedActors/Adapters.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ internal final class _ActorRefAdapter<To: Codable>: _AbstractAdapter {
6868
self.target._system
6969
}
7070

71-
func sendSystemMessage(_ message: _SystemMessage, file: String = #file, line: UInt = #line) {
71+
func sendSystemMessage(_ message: _SystemMessage, file: String = #filePath, line: UInt = #line) {
7272
switch message {
7373
case .watch(let watchee, let watcher):
7474
self.addWatcher(watchee: watchee, watcher: watcher)
@@ -82,7 +82,7 @@ internal final class _ActorRefAdapter<To: Codable>: _AbstractAdapter {
8282
}
8383

8484
@usableFromInline
85-
func trySendUserMessage(_ message: Any, file: String = #file, line: UInt = #line) {
85+
func trySendUserMessage(_ message: Any, file: String = #filePath, line: UInt = #line) {
8686
self.target._unsafeUnwrapCell.sendAdaptedMessage(message, file: file, line: line)
8787
}
8888

@@ -207,11 +207,11 @@ internal final class _DeadLetterAdapterPersonality: _AbstractAdapter {
207207
self.deadLetters._system
208208
}
209209

210-
func trySendUserMessage(_ message: Any, file: String = #file, line: UInt = #line) {
210+
func trySendUserMessage(_ message: Any, file: String = #filePath, line: UInt = #line) {
211211
self.deadLetters.tell(DeadLetter(message, recipient: self.deadRecipient, sentAtFile: file, sentAtLine: line), file: file, line: line)
212212
}
213213

214-
func sendSystemMessage(_ message: _SystemMessage, file: String = #file, line: UInt = #line) {
214+
func sendSystemMessage(_ message: _SystemMessage, file: String = #filePath, line: UInt = #line) {
215215
self.deadLetters._sendSystemMessage(message, file: file, line: line)
216216
}
217217

@@ -270,7 +270,7 @@ internal final class SubReceiveAdapter<Message: Codable, OwnerMessage: Codable>:
270270
self.target._system
271271
}
272272

273-
func sendSystemMessage(_ message: _SystemMessage, file: String = #file, line: UInt = #line) {
273+
func sendSystemMessage(_ message: _SystemMessage, file: String = #filePath, line: UInt = #line) {
274274
switch message {
275275
case .watch(let watchee, let watcher):
276276
self.addWatcher(watchee: watchee, watcher: watcher)
@@ -284,12 +284,12 @@ internal final class SubReceiveAdapter<Message: Codable, OwnerMessage: Codable>:
284284
}
285285

286286
@usableFromInline
287-
func _sendUserMessage(_ message: Message, file: String = #file, line: UInt = #line) {
287+
func _sendUserMessage(_ message: Message, file: String = #filePath, line: UInt = #line) {
288288
self.target._unsafeUnwrapCell.sendSubMessage(message, identifier: self.identifier, subReceiveAddress: self.adapterAddress)
289289
}
290290

291291
@usableFromInline
292-
func trySendUserMessage(_ message: Any, file: String = #file, line: UInt = #line) {
292+
func trySendUserMessage(_ message: Any, file: String = #filePath, line: UInt = #line) {
293293
if let message = message as? Message {
294294
self._sendUserMessage(message, file: file, line: line)
295295
} else {

Sources/DistributedActors/Behaviors.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift Distributed Actors open source project
44
//
5-
// Copyright (c) 2018-2019 Apple Inc. and the Swift Distributed Actors project authors
5+
// Copyright (c) 2018-2022 Apple Inc. and the Swift Distributed Actors project authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
@@ -599,7 +599,7 @@ extension _Behavior {
599599
///
600600
/// Note: The returned behavior MUST be `_Behavior.canonicalize`-ed in the vast majority of cases.
601601
// Implementation note: We don't do so here automatically in order to keep interpretations transparent and testable.
602-
public func interpretMessage(context: _ActorContext<Message>, message: Message, file: StaticString = #file, line: UInt = #line) throws -> _Behavior<Message> {
602+
public func interpretMessage(context: _ActorContext<Message>, message: Message, file: StaticString = #filePath, line: UInt = #line) throws -> _Behavior<Message> {
603603
switch self.underlying {
604604
case .receiveMessage(let recv): return try recv(message)
605605
case .receiveMessageAsync(let recv): return self.receiveMessageAsync(recv, message)
@@ -709,7 +709,7 @@ extension _Behavior {
709709
internal func interpretOrElse(
710710
context: _ActorContext<Message>,
711711
first: _Behavior<Message>, orElse second: _Behavior<Message>, message: Message,
712-
file: StaticString = #file, line: UInt = #line
712+
file: StaticString = #filePath, line: UInt = #line
713713
) throws -> _Behavior<Message> {
714714
var nextBehavior = try first.interpretMessage(context: context, message: message, file: file, line: line)
715715
if nextBehavior.isUnhandled {
@@ -749,7 +749,7 @@ extension _Behavior {
749749
return self
750750
}
751751

752-
internal func validateAsInitialFatal(file: String = #file, line: UInt = #line) {
752+
internal func validateAsInitialFatal(file: String = #filePath, line: UInt = #line) {
753753
switch self.underlying {
754754
case .same, .unhandled: fatalError("Illegal initial behavior! Attempted to spawn(\(self)) at \(file):\(line)")
755755
default: return

Sources/DistributedActors/Cluster/Cluster+Event.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift Distributed Actors open source project
44
//
5-
// Copyright (c) 2018-2019 Apple Inc. and the Swift Distributed Actors project authors
5+
// Copyright (c) 2018-2022 Apple Inc. and the Swift Distributed Actors project authors
66
// Licensed under Apache License v2.0
77
//
88
// See LICENSE.txt for license information
@@ -212,7 +212,7 @@ extension Cluster {
212212
#endif
213213

214214
#if DEBUG
215-
public init?(oldLeader: Cluster.Member?, newLeader: Cluster.Member?, file: String = #file, line: UInt = #line) {
215+
public init?(oldLeader: Cluster.Member?, newLeader: Cluster.Member?, file: String = #filePath, line: UInt = #line) {
216216
guard oldLeader != newLeader else {
217217
return nil
218218
}

Sources/DistributedActors/Cluster/ClusterShell+Logging.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ extension ClusterShellState {
2525
/// Enabled with `-DSACT_TRACELOG_CLUSTER`
2626
func tracelog(
2727
_ type: TraceLogType, message: Any,
28-
file: String = #file, function: String = #function, line: UInt = #line
28+
file: String = #filePath, function: String = #function, line: UInt = #line
2929
) {
3030
let level: Logger.Level?
3131
#if SACT_TRACELOG_CLUSTER
@@ -70,7 +70,7 @@ extension ClusterShell {
7070
/// Optional "dump all messages" logging.
7171
func tracelog(
7272
_ context: _ActorContext<ClusterShell.Message>, _ type: TraceLogType, message: Any,
73-
file: String = #file, function: String = #function, line: UInt = #line
73+
file: String = #filePath, function: String = #function, line: UInt = #line
7474
) {
7575
if let level = context.system.settings.traceLogLevel {
7676
context.log.log(

Sources/DistributedActors/Cluster/ClusterShell.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ internal class ClusterShell {
7272

7373
/// Get an existing association or ensure that a new one shall be stored and joining kicked off if the target node was not known yet.
7474
/// Safe to concurrently access by privileged internals directly
75-
internal func getEnsureAssociation(with node: UniqueNode, file: String = #file, line: UInt = #line) -> StoredAssociationState {
75+
internal func getEnsureAssociation(with node: UniqueNode, file: String = #filePath, line: UInt = #line) -> StoredAssociationState {
7676
self._associationsLock.withLock {
7777
if let tombstone = self._associationTombstones[node] {
7878
return .tombstone(tombstone)
@@ -106,7 +106,7 @@ internal class ClusterShell {
106106

107107
/// To be invoked by cluster shell whenever handshake is accepted, creating a completed association.
108108
/// Causes messages to be flushed onto the new associated channel.
109-
private func completeAssociation(_ associated: ClusterShellState.AssociatedDirective, file: String = #file, line: UInt = #line) throws {
109+
private func completeAssociation(_ associated: ClusterShellState.AssociatedDirective, file: String = #filePath, line: UInt = #line) throws {
110110
// 1) Complete and store the association
111111
try self._associationsLock.withLockVoid {
112112
let node: UniqueNode = associated.handshake.remoteNode

Sources/DistributedActors/Cluster/ClusterShellState.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ extension ClusterShellState {
383383
/// Does NOT by itself move the member to joining, but via the directive asks the outer to do this.
384384
mutating func completeHandshakeAssociate(
385385
_ clusterShell: ClusterShell, _ handshake: HandshakeStateMachine.CompletedState, channel: Channel,
386-
file: String = #file, line: UInt = #line
386+
file: String = #filePath, line: UInt = #line
387387
) -> AssociatedDirective {
388388
guard self._handshakes.removeValue(forKey: handshake.remoteNode.node) != nil else {
389389
fatalError("Can not complete a handshake which was not in progress!")

0 commit comments

Comments
 (0)