Improve dynamic actor isolation diagnostics
Motivation
Today, the actor isolation diagnostics are pretty confusing, especially if they come from a custom executor, which does not have as much information as the concurrency runtime about what isolation was expected. The concurrency runtime function could also accept more parameters to allow the compiler to feed through information from the type checker, such as why the expected isolation is what it is (e.g. it could have been inferred). The runtime diagnostic also does not offer any sort of solution, despite several workarounds existing.
Proposed solution
The runtime diagnostic should always state what the expected isolation was, it should give a reason for the expected isolation, and it should offer actionable guidance on how to resolve the issue.
Alternatives considered
No response
Additional information
No response
@ktoso is starting to build a general runtime entry point to support this in https://github.com/swiftlang/swift/pull/75200
The concurrency runtime function could also accept more parameters to allow the compiler to feed through information from the type checker, such as why the expected isolation is what it is
I added this information to the result of ActorIsolationRequest in https://github.com/swiftlang/swift/pull/75668, which could be used to form the diagnostic argument when emitting the dynamic isolation check in SILGen.
Definitely agree here that the messaging around this feature needs to be improved.
We started seeing crashes related to dynamic actor isolation in Xcode 16.3's toolchain (we had enabled dynamic actor isolation some time before that) and had no idea what was happening or why it was crashing.
I have a sample project to easily cause a dynamic actor isolation crash if its helpful: