Open onelittlefish opened 1 month ago
If a protocol is annotated with @MainActor, the generated mock is not main actor-isolated and doesn't compile.
@MainActor
Source:
@MainActor protocol MyProtocol { func foo() }
Generated:
public func mock(_ type: Example.MyProtocol.Protocol, file: StaticString = #file, line: UInt = #line) -> MyProtocolMock { return MyProtocolMock(sourceLocation: Mockingbird.SourceLocation(file, line)) }
The generated code results in a compile error:
Call to main actor-isolated initializer 'init(sourceLocation:)' in a synchronous nonisolated context
I think the generated mock() function needs to be @MainActor.
mock()
0.20.0
swift --version
@onelittlefish any solution to this?
New Issue Checklist
Overview
If a protocol is annotated with
@MainActor
, the generated mock is not main actor-isolated and doesn't compile.Example
Source:
Generated:
The generated code results in a compile error:
Expected Behavior
I think the generated
mock()
function needs to be@MainActor
.Environment
0.20.0
)swift --version
)