Skip to content

Commit 9864142

Browse files
committed
[Sema] Start using NonIsolatedCaller in adjustFunctionTypeForConcurrency
1 parent 1cd181d commit 9864142

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7036,15 +7036,19 @@ AnyFunctionType *swift::adjustFunctionTypeForConcurrency(
70367036

70377037
fnType = applyUnsafeConcurrencyToFunctionType(
70387038
fnType, decl, strictChecking, numApplies, isMainDispatchQueue);
7039-
Type globalActorType;
7039+
std::optional<FunctionTypeIsolation> funcIsolation;
70407040
if (decl) {
70417041
switch (auto isolation = getActorIsolation(decl)) {
70427042
case ActorIsolation::ActorInstance:
70437043
// The function type may or may not have parameter isolation.
70447044
return fnType;
70457045

7046-
case ActorIsolation::Nonisolated:
70477046
case ActorIsolation::CallerIsolationInheriting:
7047+
assert(fnType->getIsolation().isNonIsolated());
7048+
funcIsolation = FunctionTypeIsolation::forNonIsolatedCaller();
7049+
break;
7050+
7051+
case ActorIsolation::Nonisolated:
70487052
case ActorIsolation::NonisolatedUnsafe:
70497053
case ActorIsolation::Unspecified:
70507054
assert(fnType->getIsolation().isNonIsolated());
@@ -7059,20 +7063,22 @@ AnyFunctionType *swift::adjustFunctionTypeForConcurrency(
70597063
if (!strictChecking && isolation.preconcurrency())
70607064
return fnType;
70617065

7062-
globalActorType = openType(isolation.getGlobalActor());
7066+
Type globalActorType = openType(isolation.getGlobalActor());
7067+
funcIsolation = FunctionTypeIsolation::forGlobalActor(globalActorType);
70637068
break;
70647069
}
70657070
}
70667071

7067-
auto isolation = FunctionTypeIsolation::forGlobalActor(globalActorType);
7072+
ASSERT(funcIsolation.has_value());
70687073

70697074
// If there's no implicit "self" declaration, apply the isolation to
70707075
// the outermost function type.
70717076
bool hasImplicitSelfDecl = decl && (isa<EnumElementDecl>(decl) ||
70727077
(isa<AbstractFunctionDecl>(decl) &&
70737078
cast<AbstractFunctionDecl>(decl)->hasImplicitSelfDecl()));
70747079
if (!hasImplicitSelfDecl) {
7075-
return fnType->withExtInfo(fnType->getExtInfo().withIsolation(isolation));
7080+
return fnType->withExtInfo(
7081+
fnType->getExtInfo().withIsolation(*funcIsolation));
70767082
}
70777083

70787084
// Dig out the inner function type.
@@ -7082,7 +7088,7 @@ AnyFunctionType *swift::adjustFunctionTypeForConcurrency(
70827088

70837089
// Update the inner function type with the isolation.
70847090
innerFnType = innerFnType->withExtInfo(
7085-
innerFnType->getExtInfo().withIsolation(isolation));
7091+
innerFnType->getExtInfo().withIsolation(*funcIsolation));
70867092

70877093
// Rebuild the outer function type around it.
70887094
if (auto genericFnType = dyn_cast<GenericFunctionType>(fnType)) {

0 commit comments

Comments
 (0)