Question about the behaviour of `@isolated(any)`

IIUC, the @Sendable annotation on the parameter effectively means the closure will be inferred to be nonisolated in this case. @isolated(any) doesn't affect inference rules, it just allows storing the inferred isolation within the function reference. if you want to get the 'inherit the surrounding actor context' behavior on a @Sendable or sending closure parameter, you'll need to resort to using the unformalized @_inheritActorContext attribute. this thread has some more info on the distinction between these attributes. if you add the underscored attribute, i think the isolation inference will be more like what you expect (godbolt example here).

5 Likes