Framework for automatic mock generation. Adds a set of handy methods, simplifying testing. One of the best and most complete solutions, including generics support and much more.
MIT License
1.03k
stars
104
forks
source link
Incorrect mock generation with @MainActor in closure of async method #316
We use async functions for network operations and then pass the result with closure blocks up to our ViewControllers. It’s very convenient to declare @MainActor directly in closure to switch to the main queue:
With 2 compiler errors when adding .value(completion):
`Converting function value of type '@MainActor (Result<Void, Error>) -> Void' to '(Result<Void, Error>) -> Void' loses global actor 'MainActor'`
I’ve been looking through issues (i.e. #290, #304) but mine looks new.
It seems to be an easy fix in some way. We either need to add @MainActor to MethodType or just ignore it while parsing (looks like it’s not that necessary to mock it at all).
Hi!
We use async functions for network operations and then pass the result with closure blocks up to our ViewControllers. It’s very convenient to declare @MainActor directly in closure to switch to the main queue:
Anyway, in our Mock.generated we got this:
With 2 compiler errors when adding
.value(completion)
:I’ve been looking through issues (i.e. #290, #304) but mine looks new.
It seems to be an easy fix in some way. We either need to add @MainActor to MethodType or just ignore it while parsing (looks like it’s not that necessary to mock it at all).