Skip to content

Commit

Permalink
WIP: Provide isolated actor for async init
Browse files Browse the repository at this point in the history
Try to workaround apple#71174, which crashes Swift with
an async initializer with isolated actor argument.

I have no idea what I am doing.
  • Loading branch information
niw committed Apr 24, 2024
1 parent 3fe8b71 commit 0e93842
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/SILGen/SILGenConcurrency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,15 @@ void SILGenFunction::emitConstructorPrologActorHop(
SILLocation loc, std::optional<ActorIsolation> maybeIso) {
loc = loc.asAutoGenerated();
if (maybeIso) {
if (auto executor = emitExecutor(loc, *maybeIso, std::nullopt)) {
auto iso = *maybeIso;
std::optional<ManagedValue> maybeSelf;
if (iso == ActorIsolation::ActorInstance) {
auto actor = iso.getActorInstance();
Type actorType = actor->getTypeInContext();
RValue actorInstanceRV = emitRValueForDecl(loc, actor, actorType, AccessSemantics::Ordinary);
maybeSelf = std::move(actorInstanceRV).getScalarValue();
}
if (auto executor = emitExecutor(loc, iso, maybeSelf)) {
ExpectedExecutor = *executor;
}
}
Expand Down

0 comments on commit 0e93842

Please sign in to comment.