Merge pull request #82868 from rjmccall/dont-capture-defer-isolation-6.2

[6.2] Don't force a capture of an isolated parameter in defer bodies
This commit is contained in:
John McCall
2025-07-08 11:58:33 -04:00
committed by GitHub
4 changed files with 67 additions and 6 deletions

View File

@@ -136,7 +136,8 @@ void SILGenFunction::emitExpectedExecutorProlog() {
// Defer bodies are always called synchronously within their enclosing
// function, so the check is unnecessary; in addition, we cannot
// necessarily perform the check because the defer may not have
// captured the isolated parameter of the enclosing function.
// captured the isolated parameter of the enclosing function, and
// forcing a capture would cause DI problems in actor initializers.
bool wantDataRaceChecks = [&] {
if (F.isAsync() || F.isDefer())
return false;