mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[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:
@@ -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()};
|
||||
|
||||
Reference in New Issue
Block a user