@@ -7036,15 +7036,19 @@ AnyFunctionType *swift::adjustFunctionTypeForConcurrency(
7036
7036
7037
7037
fnType = applyUnsafeConcurrencyToFunctionType (
7038
7038
fnType, decl, strictChecking, numApplies, isMainDispatchQueue);
7039
- Type globalActorType ;
7039
+ std::optional<FunctionTypeIsolation> funcIsolation ;
7040
7040
if (decl) {
7041
7041
switch (auto isolation = getActorIsolation (decl)) {
7042
7042
case ActorIsolation::ActorInstance:
7043
7043
// The function type may or may not have parameter isolation.
7044
7044
return fnType;
7045
7045
7046
- case ActorIsolation::Nonisolated:
7047
7046
case ActorIsolation::CallerIsolationInheriting:
7047
+ assert (fnType->getIsolation ().isNonIsolated ());
7048
+ funcIsolation = FunctionTypeIsolation::forNonIsolatedCaller ();
7049
+ break ;
7050
+
7051
+ case ActorIsolation::Nonisolated:
7048
7052
case ActorIsolation::NonisolatedUnsafe:
7049
7053
case ActorIsolation::Unspecified:
7050
7054
assert (fnType->getIsolation ().isNonIsolated ());
@@ -7059,20 +7063,22 @@ AnyFunctionType *swift::adjustFunctionTypeForConcurrency(
7059
7063
if (!strictChecking && isolation.preconcurrency ())
7060
7064
return fnType;
7061
7065
7062
- globalActorType = openType (isolation.getGlobalActor ());
7066
+ Type globalActorType = openType (isolation.getGlobalActor ());
7067
+ funcIsolation = FunctionTypeIsolation::forGlobalActor (globalActorType);
7063
7068
break ;
7064
7069
}
7065
7070
}
7066
7071
7067
- auto isolation = FunctionTypeIsolation::forGlobalActor (globalActorType );
7072
+ ASSERT (funcIsolation. has_value () );
7068
7073
7069
7074
// If there's no implicit "self" declaration, apply the isolation to
7070
7075
// the outermost function type.
7071
7076
bool hasImplicitSelfDecl = decl && (isa<EnumElementDecl>(decl) ||
7072
7077
(isa<AbstractFunctionDecl>(decl) &&
7073
7078
cast<AbstractFunctionDecl>(decl)->hasImplicitSelfDecl ()));
7074
7079
if (!hasImplicitSelfDecl) {
7075
- return fnType->withExtInfo (fnType->getExtInfo ().withIsolation (isolation));
7080
+ return fnType->withExtInfo (
7081
+ fnType->getExtInfo ().withIsolation (*funcIsolation));
7076
7082
}
7077
7083
7078
7084
// Dig out the inner function type.
@@ -7082,7 +7088,7 @@ AnyFunctionType *swift::adjustFunctionTypeForConcurrency(
7082
7088
7083
7089
// Update the inner function type with the isolation.
7084
7090
innerFnType = innerFnType->withExtInfo (
7085
- innerFnType->getExtInfo ().withIsolation (isolation ));
7091
+ innerFnType->getExtInfo ().withIsolation (*funcIsolation ));
7086
7092
7087
7093
// Rebuild the outer function type around it.
7088
7094
if (auto genericFnType = dyn_cast<GenericFunctionType>(fnType)) {
0 commit comments