That makes sense, thanks. Perhaps the work function doesn't need to be an instance method of AnalysisLoader, then. @ConfusedVorlon does it actually access any instance members of self? Changing it to be a static method or top-level function would also fix the warning.
I got a whole bunch of sendable warnings with 16.2 RC
(image in the vision thread)
It does.
Tbh though - the answer to that question would always be case specific. There will be at least some cases where a static method isn't a good solution. I'm more concerned about the direction of travel than the implications on this specific class.
I suggest you also turn on the upcoming features "Region Based Isolation", "Isolated Default Values", and "Infer Sendable for Methods and Key Path Literals". Helps even minimal checking be more intelligent.
I now understand why the US government is pushing the open source community towards rust and away from c/c++ languages. Next they will place the same recommendations on swift if programmers with this mindset can’t adopt to the best practices related to code quality and safety.
withCheckedContinuation should init and own the AnalysisLoader object.
But your design is wrong. Move this analyse async func out of this class into its own controller struct, call that AnalysisLoader. Pass your model as a parm into the async func it for it to work on, call that model AnalysisModel.
Think of async/await as controller funcs that work on your objects "from the outside". You can't have async funcs inside model classes because if the funcs are called simultaneously your model will be corrupt and now Swift 6 won't allow it.
It's weird for you to so confidently tell me my design is wrong given that you haven't seen the class or what it does.
It has one job which is to run the analyse function.
That function accesses some state that is loaded at init, and breaks the work into various private functions for clarity.
The only code you have seen is the async wrapper around that analyse function. And in fact, this async wrapper is the only non-private method on the class.
Perhaps Swift 6 really does require an async wrapper to exist in it's own controller class. If so - that seems pretty badly designed to me.
With Swift you are supposed to choose struct first and change to use class when you need to control identity of some data. So most people wouldn't have put async func in class in the first place because they'd have a struct. I wouldn't call this an "async wrapper".