@@ -226,6 +226,10 @@ public final class FakeRoundtripActorSystem: DistributedActorSystem, @unchecked
226
226
227
227
public init ( ) { }
228
228
229
+ public func shutdown( ) {
230
+ self . activeActors = [ : ]
231
+ }
232
+
229
233
public func resolve< Act> ( id: ActorID , as actorType: Act . Type )
230
234
throws -> Act ? where Act: DistributedActor {
231
235
print ( " | resolve \( id) as remote // this system always resolves as remote " )
@@ -394,7 +398,14 @@ public struct FakeInvocationEncoder : DistributedTargetInvocationEncoder {
394
398
print ( " > done recording " )
395
399
}
396
400
397
- public func makeDecoder( ) -> FakeInvocationDecoder {
401
+ public mutating func makeDecoder( ) -> FakeInvocationDecoder {
402
+ defer {
403
+ // reset the decoder; we don't want to keep these values retained by accident here
404
+ genericSubs = [ ]
405
+ arguments = [ ]
406
+ returnType = nil
407
+ errorType = nil
408
+ }
398
409
return . init(
399
410
args: arguments,
400
411
substitutions: genericSubs,
@@ -406,32 +417,13 @@ public struct FakeInvocationEncoder : DistributedTargetInvocationEncoder {
406
417
407
418
// === decoding --------------------------------------------------------------
408
419
409
- class Guardian {
410
- let type : String
411
- let file : String
412
- let line : UInt
413
-
414
- init ( _ type: any Any . Type , file: String = #fileID, line: UInt = #line) {
415
- self . type = " \( type) "
416
- self . file = file
417
- self . line = line
418
- print ( " init Guardian( \( type) ) @ \( file) : \( line) " )
419
- }
420
-
421
- deinit {
422
- print ( " deinit Guardian( \( type) ) @ \( file) : \( line) " )
423
- }
424
- }
425
-
426
420
// !!! WARNING !!!
427
421
// This is a 'final class' on purpose, to see that we retain the ad-hoc witness
428
422
// for 'decodeNextArgument'; Do not change it to just a class!
429
423
@available ( SwiftStdlib 5 . 7 , * )
430
424
public final class FakeInvocationDecoder : DistributedTargetInvocationDecoder {
431
425
public typealias SerializationRequirement = Codable
432
426
433
- let x = Guardian ( FakeInvocationDecoder . self)
434
-
435
427
var genericSubs : [ Any . Type ] = [ ]
436
428
var arguments : [ Any ] = [ ]
437
429
var returnType : Any . Type ? = nil
@@ -466,8 +458,6 @@ public final class FakeInvocationDecoder: DistributedTargetInvocationDecoder {
466
458
fatalError ( " Cannot cast argument \( anyArgument) to expected \( Argument . self) " )
467
459
}
468
460
469
- arguments = [ ]
470
-
471
461
print ( " > decode argument: \( argument) " )
472
462
argumentIndex += 1
473
463
return argument
0 commit comments