You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you annotate a protocol with a global actor, such as @mainactor, its generate mock doesn't compile:
Given
/// @mockable
@MainActor
protocol RootController: AnyObject {
var viewController: UIViewController { get }
}
the mock will fail with this compilation error:
❌ /usr/local/var/buildkite-agent/builds/7003-local-1/varun-santhanam/{}/Project/{}Tests/Mocks.swift:226:16: call to main actor-isolated initializer 'init()' in a synchronous nonisolated context
--
| return RootControllerMock()
The solution, I believe, would be to also add the actor annotation to the Mock
An identically generated mock, with the @MainActor annotation would work just fine.
I believe there would be similar errors for per-member annotations as well.
The text was updated successfully, but these errors were encountered:
Seems to be happening even on 1.7
note that generating the mocks isn't the problem. Its that the mocks aren't compilable.
❌ /Users/vsanthanam/Desktop/convusic-monorepo/Project/ConvusicMobileTests/Mocks.swift:498:16: call to main actor-isolated initializer 'init()' in a synchronous nonisolated context
return MainControllerMock()
The mocks cannot invoke the initializers of their actor dependent mocks because they are not annotated correctly
Here's an attached generated but non-compiling example: Mocks.swift.txt
If you annotate a protocol with a global actor, such as @mainactor, its generate mock doesn't compile:
Given
the mock will fail with this compilation error:
The solution, I believe, would be to also add the actor annotation to the Mock
An identically generated mock, with the
@MainActor
annotation would work just fine.I believe there would be similar errors for per-member annotations as well.
The text was updated successfully, but these errors were encountered: