new fear unlocked

how are we supposed to implement the delegate pattern now in Swift?

just throwing "@unchecked Sendable" randomly on it and moving with our lives is not the solution I was hoping for
@krzyzanowskim yeah I honestly do not know how to solve this. The delegate reference could be zeroed on any thread, how can that possibly be thread safe? Maybe only if both Foo and FooDelegate are MainActor isolated, which may not be appropriate.

@krzyzanowskim

I believe you can put a weak var in an actor without a warning. If Foo can't be an actor itself, you could have some sort of inner actor where you store the weak var instead.

@krzyzanowskim

Something like this. Not saying it's awesome, but it works.

@krzyzanowskim

Someone will inevitably tell you to just not use a delegate pattern because delegate patterns are unequivocally bad or whatever.

Unfortunately, some problems just don't have a more elegant alternative solution.

@krzyzanowskim set Swift 5 in project settings and ignore this non-sense?
@krzyzanowskim I think we'll end up marking those all @‘MainActor (or another global actor), at least for UI related delegates. And then we'll have to figure out a different pattern for elements that we don't want to be actor-isolated.