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
I have read CONTRIBUTING and have done my best to follow them.
What did you do?
I recently updated my project to use SWIFT_STRICT_CONCURRENCY=targeted. After doing so, Nimble is giving the following warnings when using toEventually():
// Non-sendable type 'SyncExpectation<FooViewModel.State>' returned by implicitly asynchronous call to nonisolated function cannot cross actor boundary
// Passing argument of non-sendable type 'Matcher<FooViewModel.State>' outside of main actor-isolated context may introduce data races
@MainActorfinalclassExampleTestSpec:AsyncSpec{overrideclassfunc spec(){varfooVM:FooViewModel!beforeEach{@MainActorin
fooVM =FooViewModel()}it("sets states"){@MainActorin// This works fineexpect(fooVM.state).to(equal(FooViewModel.State(val:"val")))}it("eventually sets state"){@MainActorin// This gives two warnings:// Non-sendable type 'SyncExpectation<FooViewModel.State>' returned by implicitly asynchronous call to nonisolated function cannot cross actor boundary// Passing argument of non-sendable type 'Matcher<FooViewModel.State>' outside of main actor-isolated context may introduce data racesawaitexpect(fooVM.state).toEventually(equal(FooViewModel.State(val:"val")))}}}
Reasoning around @MainActor usage: Since we're testing a ViewModel here, we want to isolate everything to run on the main actor.
Please feel free to suggest an alternative way but right now, I think the only feasible workarounds available are:
Use @preconcurrency import Nimble to silence the warnings
Use @unchecked Sendable to silence the warnings
Neither of the above workarounds are ideal. I'm curious to understand why SyncExpectation and Matcher don't conform to Sendable. Is there a plan to add this conformance soon? If not then what approach would you suggest in this situation?
What did you expect to happen?
I expected no warnings.
What actually happened instead?
I got two warnings around SyncExpectation and Matcher being non-sendable types.
Environment
List the software versions you're using:
Quick: 7.3.0
Nimble: 13.1.2
Xcode Version: 15.1 (15C65)
Swift Version: 5.9.2
Please also mention which package manager you used and its version. Delete the
other package managers in this list:
Swift Package Manager: Swift Package Manager - Swift 5.9.0
The text was updated successfully, but these errors were encountered:
This is being worked on for the next major version of Nimble. There's a lot involved in this, though. Especially to keep a decent experience when using with Quick.
@younata that's great to hear. I'll continue to use @preconcurrency import for now then. Any idea what kind of time horizon, we are looking at for this release?
Any idea what kind of time horizon, we are looking at for this release?
I'd like to get Nimble 14 out before September, with betas running during the summer. No promises though - I'm not going to burn myself out for a hobby project.
What did you do?
I recently updated my project to use
SWIFT_STRICT_CONCURRENCY=targeted
. After doing so, Nimble is giving the following warnings when usingtoEventually()
:Here's some code to reproduce the problem:
The subject being tested:
The Spec:
Reasoning around
@MainActor
usage: Since we're testing a ViewModel here, we want to isolate everything to run on the main actor.Please feel free to suggest an alternative way but right now, I think the only feasible workarounds available are:
@preconcurrency import Nimble
to silence the warnings@unchecked Sendable
to silence the warningsNeither of the above workarounds are ideal. I'm curious to understand why
SyncExpectation
andMatcher
don't conform toSendable
. Is there a plan to add this conformance soon? If not then what approach would you suggest in this situation?What did you expect to happen?
I expected no warnings.
What actually happened instead?
I got two warnings around
SyncExpectation
andMatcher
being non-sendable types.Environment
List the software versions you're using:
Please also mention which package manager you used and its version. Delete the
other package managers in this list:
The text was updated successfully, but these errors were encountered: