swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.31k stars 10.34k forks source link

Improve dynamic actor isolation diagnostics #75508

Open hborla opened 1 month ago

hborla commented 1 month ago

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

hborla commented 1 month ago

@ktoso is starting to build a general runtime entry point to support this in https://github.com/swiftlang/swift/pull/75200

hborla commented 1 month ago

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.