Surfacing Isolation through tools

I was reading this blog post about a cute little algorithm to run in your head to trace where a symbol’s isolation is defined, and it got me thinking: why are we making developers responsible for figuring this out? Since isolation is statically determined, shouldn’t the language server be able to tell us exactly which actor we’re isolated to? I envision something like this:

  1. If you hover over a symbol, the isolation domain pops up.
  2. Some key shortcut will put you in an “isolation view” similar to code coverage that highest lines of code with colors according to the actor they will be executed on.

Is there any reason this isn’t feasible, besides maybe SourceKit lacking the relevant diagnostics? The only thing that comes to mind is isolated parameters are dynamic in a sense that you don’t know anything more about the actor besides there is one passed into the function, but maybe it could still at least point to where the function is used and which actors it could be isolated to.

I’m not sure if region based isolation would play well with this, haven’t thought enough about that.

But in the current paradigm, I can’t stress enough how helpful this could be to debugging concurrency issues that require you to hold this big graph in your head of who is isolated to what.


Hey @dannflor,

We did already add closure isolation annotations to Quick Help for declarations in [Concurrency] Never skip global actor attributes in the ASTPrinter. by hborla · Pull Request #72037 · apple/swift · GitHub. You should be able to try this by using a nightly Swift development snapshot from - Download Swift.

Adding the same for closures makes total sense. I filed Show a closure’s type and actor isolation when performing cursor info on the braces or `in` keyword · Issue #73095 · apple/swift · GitHub for that.