@@ -1889,8 +1889,7 @@ static ActorIsolation getInnermostIsolatedContext(
18891889 case ActorIsolation::GlobalActor:
18901890 case ActorIsolation::GlobalActorUnsafe:
18911891 return ActorIsolation::forGlobalActor (
1892- dc->mapTypeIntoContext (isolation.getGlobalActor ()),
1893- isolation == ActorIsolation::GlobalActorUnsafe)
1892+ dc->mapTypeIntoContext (isolation.getGlobalActor ()))
18941893 .withPreconcurrency (isolation.preconcurrency ());
18951894 }
18961895}
@@ -3238,8 +3237,7 @@ namespace {
32383237 // we are within that global actor already.
32393238 if (!(getContextIsolation ().isGlobalActor () &&
32403239 getContextIsolation ().getGlobalActor ()->isEqual (globalActor))) {
3241- unsatisfiedIsolation = ActorIsolation::forGlobalActor (
3242- globalActor, /* unsafe=*/ false );
3240+ unsatisfiedIsolation = ActorIsolation::forGlobalActor (globalActor);
32433241 }
32443242
32453243 mayExitToNonisolated = false ;
@@ -3891,7 +3889,7 @@ namespace {
38913889
38923890 // If the closure specifies a global actor, use it.
38933891 if (Type globalActor = resolveGlobalActorType (explicitClosure))
3894- return ActorIsolation::forGlobalActor (globalActor, /* unsafe= */ false )
3892+ return ActorIsolation::forGlobalActor (globalActor)
38953893 .withPreconcurrency (preconcurrency);
38963894 }
38973895
@@ -3927,7 +3925,7 @@ namespace {
39273925 case ActorIsolation::GlobalActorUnsafe: {
39283926 Type globalActor = closure->mapTypeIntoContext (
39293927 parentIsolation.getGlobalActor ()->mapTypeOutOfContext ());
3930- return ActorIsolation::forGlobalActor (globalActor, /* unsafe= */ false )
3928+ return ActorIsolation::forGlobalActor (globalActor)
39313929 .withPreconcurrency (preconcurrency);
39323930 }
39333931
@@ -4124,7 +4122,7 @@ getIsolationFromAttributes(const Decl *decl, bool shouldDiagnose = true,
41244122 isUnsafe = true ;
41254123
41264124 return ActorIsolation::forGlobalActor (
4127- globalActorType->mapTypeOutOfContext (), isUnsafe )
4125+ globalActorType->mapTypeOutOfContext ())
41284126 .withPreconcurrency (decl->preconcurrency () || isUnsafe);
41294127 }
41304128
@@ -4216,8 +4214,8 @@ getIsolationFromWitnessedRequirements(ValueDecl *value) {
42164214 return true ;
42174215
42184216 // Update the global actor type, now that we've done this substitution.
4219- std::get<1 >(isolated) = ActorIsolation::forGlobalActor (
4220- globalActor, isolation == ActorIsolation::GlobalActorUnsafe );
4217+ std::get<1 >(isolated) = ActorIsolation::forGlobalActor (globalActor)
4218+ . withPreconcurrency ( isolation. preconcurrency () );
42214219 return false ;
42224220 }
42234221 }
@@ -4461,8 +4459,7 @@ getActorIsolationForMainFuncDecl(FuncDecl *fnDecl) {
44614459
44624460 return isMainFunction && hasMainActor
44634461 ? ActorIsolation::forGlobalActor (
4464- ctx.getMainActorType ()->mapTypeOutOfContext (),
4465- /* isUnsafe*/ false )
4462+ ctx.getMainActorType ()->mapTypeOutOfContext ())
44664463 : llvm::Optional<ActorIsolation>();
44674464}
44684465
@@ -4906,8 +4903,8 @@ ActorIsolation ActorIsolationRequest::evaluate(
49064903 var->getDeclContext ()->isAsyncContext ())) {
49074904 if (Type mainActor = var->getASTContext ().getMainActorType ())
49084905 return inferredIsolation (
4909- ActorIsolation::forGlobalActor (mainActor,
4910- /* unsafe= */ var->preconcurrency () ));
4906+ ActorIsolation::forGlobalActor (mainActor))
4907+ . withPreconcurrency ( var->preconcurrency ());
49114908 }
49124909 if (auto isolation = getActorIsolationFromWrappedProperty (var))
49134910 return inferredIsolation (isolation);
@@ -4993,7 +4990,8 @@ ActorIsolation ActorIsolationRequest::evaluate(
49934990 ASTContext &ctx = value->getASTContext ();
49944991 if (Type mainActor = ctx.getMainActorType ()) {
49954992 return inferredIsolation (
4996- ActorIsolation::forGlobalActor (mainActor, /* unsafe=*/ true ));
4993+ ActorIsolation::forGlobalActor (mainActor)
4994+ .withPreconcurrency (true ));
49974995 }
49984996 }
49994997
@@ -5907,14 +5905,12 @@ AnyFunctionType *swift::adjustFunctionTypeForConcurrency(
59075905 return fnType;
59085906
59095907 case ActorIsolation::GlobalActorUnsafe:
5910- // Only treat as global-actor-qualified within code that has adopted
5911- // Swift Concurrency features.
5912- if (!strictChecking)
5908+ case ActorIsolation::GlobalActor:
5909+ // For preconcurrency, only treat as global-actor-qualified
5910+ // within code that has adopted Swift Concurrency features.
5911+ if (!strictChecking && isolation.preconcurrency ())
59135912 return fnType;
59145913
5915- LLVM_FALLTHROUGH;
5916-
5917- case ActorIsolation::GlobalActor:
59185914 globalActorType = openType (isolation.getGlobalActor ());
59195915 break ;
59205916 }
@@ -6058,22 +6054,19 @@ static ActorIsolation getActorIsolationForReference(
60586054 ValueDecl *decl, const DeclContext *fromDC) {
60596055 auto declIsolation = getActorIsolation (decl);
60606056
6061- // If the isolation is "unsafe" global actor isolation , adjust it based on
6057+ // If the isolation is preconcurrency global actor, adjust it based on
60626058 // context itself. For contexts that require strict checking, treat it as
60636059 // global actor isolation. Otherwise, treat it as unspecified isolation.
6064- if (declIsolation == ActorIsolation::GlobalActorUnsafe) {
6065- if (contextRequiresStrictConcurrencyChecking (
6060+ if (declIsolation == ActorIsolation::GlobalActor &&
6061+ declIsolation.preconcurrency ()) {
6062+ if (!contextRequiresStrictConcurrencyChecking (
60666063 fromDC,
60676064 [](const AbstractClosureExpr *closure) {
60686065 return closure->getType ();
60696066 },
60706067 [](const ClosureExpr *closure) {
60716068 return closure->isIsolatedByPreconcurrency ();
60726069 })) {
6073- declIsolation = ActorIsolation::forGlobalActor (
6074- declIsolation.getGlobalActor (), /* unsafe=*/ false )
6075- .withPreconcurrency (declIsolation.preconcurrency ());
6076- } else {
60776070 declIsolation = ActorIsolation::forUnspecified ();
60786071 }
60796072 }
0 commit comments