Hm, okay, I was considering you might have left that out, but then that code does not produce any error, I believe? At least when I tried it out it does not?
Admittedly I could have also noticed that the error message you gave does not at all match what you'd get when simply not making the function async
... that's my bad. That would be the much more obvious 'async' call in a function that does not support concurrency
...
Your example obviously leaves out the part where the expectation is fulfilled, so I quickly spun up this:
@MainActor
func test_bla() async {
let something = expectation(description: "bla")
Task {
try? await Task.sleep(for: .seconds(1.0))
something.fulfill()
}
await fulfillment(of: [something])
}
That compiles and runs without any problems in my freshly updated Xcode, even with -strict-concurrency=complete
. Perhaps that was a last little bug that had been fixed in the final release?
The only other reason I could see is in how you use whatever instance of the type to test you have to fulfill the expectation... I find myself often using an [unowned self]
capture list in some closures I use to do so, as I tend to have an underTest
property in my test's instance that I use to, well, test...
If the warning in this case is still there, can you maybe give a more concrete example that I could try to reproduce it with?
As said I was able to simply make all my functions @MainActor
where I had previously used test cases annotated that way, but none of those were actually async
...