@@ -3115,6 +3115,23 @@ swift::determineClosureActorIsolation(AbstractClosureExpr *closure) {
3115
3115
return checker.determineClosureIsolation (closure);
3116
3116
}
3117
3117
3118
+ // / Determine whethere there is an explicit isolation attribute
3119
+ // / of any kind.
3120
+ static bool hasExplicitIsolationAttribute (const Decl *decl) {
3121
+ if (auto nonisolatedAttr =
3122
+ decl->getAttrs ().getAttribute <NonisolatedAttr>()) {
3123
+ if (!nonisolatedAttr->isImplicit ())
3124
+ return true ;
3125
+ }
3126
+
3127
+ if (auto globalActorAttr = decl->getGlobalActorAttr ()) {
3128
+ if (!globalActorAttr->first ->isImplicit ())
3129
+ return true ;
3130
+ }
3131
+
3132
+ return false ;
3133
+ }
3134
+
3118
3135
// / Determine actor isolation solely from attributes.
3119
3136
// /
3120
3137
// / \returns the actor isolation determined from attributes alone (with no
@@ -4085,8 +4102,7 @@ bool swift::contextRequiresStrictConcurrencyChecking(
4085
4102
} else if (auto decl = dc->getAsDecl ()) {
4086
4103
// If any isolation attributes are present, we're using concurrency
4087
4104
// features.
4088
- if (getIsolationFromAttributes (
4089
- decl, /* shouldDiagnose=*/ false , /* onlyExplicit=*/ true ))
4105
+ if (hasExplicitIsolationAttribute (decl))
4090
4106
return true ;
4091
4107
4092
4108
if (auto func = dyn_cast<AbstractFunctionDecl>(decl)) {
@@ -4097,9 +4113,7 @@ bool swift::contextRequiresStrictConcurrencyChecking(
4097
4113
// If we're in an accessor declaration, also check the storage
4098
4114
// declaration.
4099
4115
if (auto accessor = dyn_cast<AccessorDecl>(decl)) {
4100
- if (getIsolationFromAttributes (
4101
- accessor->getStorage (), /* shouldDiagnose=*/ false ,
4102
- /* onlyExplicit=*/ true ))
4116
+ if (hasExplicitIsolationAttribute (accessor->getStorage ()))
4103
4117
return true ;
4104
4118
}
4105
4119
}
0 commit comments