-
-
Notifications
You must be signed in to change notification settings - Fork 171
Open
Description
Hi I'm upgrading my SPM Packages to Swift 6.2, and also upgrading Factory to 2.5.3
I'm registering a dependency for the main actor
extension Container {
@MainActor
var mainActorType: Factory<MainActorType> {
self { @MainActor in SomeMainActorType() }
}
} And I have a XCTestCase also for the main actor where I override the registration
@MainActor
final class MyTests: XCTestCase {
private var mockMainActorInstance: MockMainActorType!
override func setUp() async throws {
Container.shared.mainActorType.register { params in
self.mockMainActorInstance = MockMainActorType(withParams: params)
return self.mockMainActorInstance
}
}
}But I get the error
Main actor-isolated property 'mockMainActorInstance' can not be referenced from a Sendable closure
Looking at the Factory code it looks like adding @mainactor to the closure parameter could/should resolve this issue
public extension Factory {
@discardableResult
func registerMain(factory: @MainActor @escaping () -> T) -> Self {
self.register(factory: factory)
return self
}
}markusfassbender-lb
Metadata
Metadata
Assignees
Labels
No labels