Ensure that distributed functions with typed throws can be called from outside

When calling a distributed function for an actor that might not be local,
the call can throw due to the distributed actor system producing an
error. The function might, independently, also throw. When the
function uses typed throws, we incorrectly treated the call is if it
would always throw the error type specified by the function. This
leads to incorrectly accepting invalid code, and compiler crashes in
SILGen.

The change here is to always mark calls to distributed functions
outside the actor as "implicitly throwing", which makes sure that we
treat the call sites as throwing 'any Error'. The actual handling of
the typed throw (from the local function) and the untyped throw (from
the distributed actor system) occurs in thunk generation in SILGen,
and was already handled correctly.

Fixes rdar://144093249, and undoes the ban introduced by rdar://136467528
This commit is contained in:
Doug Gregor
2025-02-04 15:51:00 -08:00
parent d620886106
commit 84ed66f3be
6 changed files with 78 additions and 54 deletions

View File

@@ -5656,9 +5656,6 @@ ERROR(distributed_actor_func_unsupported_specifier, none,
ERROR(distributed_actor_func_variadic, none,
"cannot declare variadic argument %0 in %kind1",
(DeclName, const ValueDecl *))
ERROR(distributed_actor_func_typed_throws, none,
"cannot declare distributed function with typed throws",
())
NOTE(actor_mutable_state,none,
"mutation of this %0 is only permitted within the actor",
(DescriptiveDeclKind))