[Concurrency] NonisolatedNonsendingByDefault: Extend nonisolated(nonsending) to _openExistential

`_openExistential` is type-checked in a special way which
means that we need to explicitly inject `nonisolated(nonsending)`
isolation when forming a reference to this builtin.

(cherry picked from commit 358869ff54)
This commit is contained in:
Pavel Yaskevich
2025-07-17 17:27:13 -07:00
parent 18817b823f
commit fb0daaa78a
2 changed files with 30 additions and 0 deletions

View File

@@ -2374,20 +2374,36 @@ static DeclReferenceType getTypeOfReferenceWithSpecialTypeCheckingSemantics(
CS.getConstraintLocator(locator, ConstraintLocator::ThrownErrorType),
0);
FunctionType::Param bodyArgs[] = {FunctionType::Param(openedTy)};
auto bodyParamIsolation = FunctionTypeIsolation::forNonIsolated();
if (CS.getASTContext().LangOpts.hasFeature(
Feature::NonisolatedNonsendingByDefault)) {
bodyParamIsolation = FunctionTypeIsolation::forNonIsolatedCaller();
}
auto bodyClosure = FunctionType::get(bodyArgs, result,
FunctionType::ExtInfoBuilder()
.withNoEscape(true)
.withThrows(true, thrownError)
.withIsolation(bodyParamIsolation)
.withAsync(true)
.build());
FunctionType::Param args[] = {
FunctionType::Param(existentialTy),
FunctionType::Param(bodyClosure, CS.getASTContext().getIdentifier("do")),
};
auto openExistentialIsolation = FunctionTypeIsolation::forNonIsolated();
if (CS.getASTContext().LangOpts.hasFeature(
Feature::NonisolatedNonsendingByDefault)) {
openExistentialIsolation = FunctionTypeIsolation::forNonIsolatedCaller();
}
auto refType = FunctionType::get(args, result,
FunctionType::ExtInfoBuilder()
.withNoEscape(false)
.withThrows(true, thrownError)
.withIsolation(openExistentialIsolation)
.withAsync(true)
.build());
return {refType, refType, refType, refType, Type()};