-
Notifications
You must be signed in to change notification settings - Fork 90
Open
Labels
generator bugCauses malformed generated codeCauses malformed generated code
Description
New Issue Checklist
- I updated the framework and generator to the latest version
- I searched the existing GitHub issues and list of common problems
Overview
If a protocol is annotated with @MainActor, the generated mock is not main actor-isolated and doesn't compile.
Example
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
Expected Behavior
I think the generated mock() function needs to be @MainActor.
Environment
- Mockingbird CLI version (
0.20.0) - Xcode and Swift version (
swift --version) - Package manager (SPM project)
- Unit testing framework (XCTest)
- Custom configuration
- Mockingbird ignore files
- Supporting source files
Metadata
Metadata
Assignees
Labels
generator bugCauses malformed generated codeCauses malformed generated code