@@ -3055,6 +3055,23 @@ swift::determineClosureActorIsolation(AbstractClosureExpr *closure) {
3055
3055
return checker.determineClosureIsolation (closure);
3056
3056
}
3057
3057
3058
+ // / Determine whethere there is an explicit isolation attribute
3059
+ // / of any kind.
3060
+ static bool hasExplicitIsolationAttribute (const Decl *decl) {
3061
+ if (auto nonisolatedAttr =
3062
+ decl->getAttrs ().getAttribute <NonisolatedAttr>()) {
3063
+ if (!nonisolatedAttr->isImplicit ())
3064
+ return true ;
3065
+ }
3066
+
3067
+ if (auto globalActorAttr = decl->getGlobalActorAttr ()) {
3068
+ if (!globalActorAttr->first ->isImplicit ())
3069
+ return true ;
3070
+ }
3071
+
3072
+ return false ;
3073
+ }
3074
+
3058
3075
// / Determine actor isolation solely from attributes.
3059
3076
// /
3060
3077
// / \returns the actor isolation determined from attributes alone (with no
@@ -4025,8 +4042,7 @@ bool swift::contextRequiresStrictConcurrencyChecking(
4025
4042
} else if (auto decl = dc->getAsDecl ()) {
4026
4043
// If any isolation attributes are present, we're using concurrency
4027
4044
// features.
4028
- if (getIsolationFromAttributes (
4029
- decl, /* shouldDiagnose=*/ false , /* onlyExplicit=*/ true ))
4045
+ if (hasExplicitIsolationAttribute (decl))
4030
4046
return true ;
4031
4047
4032
4048
if (auto func = dyn_cast<AbstractFunctionDecl>(decl)) {
@@ -4037,9 +4053,7 @@ bool swift::contextRequiresStrictConcurrencyChecking(
4037
4053
// If we're in an accessor declaration, also check the storage
4038
4054
// declaration.
4039
4055
if (auto accessor = dyn_cast<AccessorDecl>(decl)) {
4040
- if (getIsolationFromAttributes (
4041
- accessor->getStorage (), /* shouldDiagnose=*/ false ,
4042
- /* onlyExplicit=*/ true ))
4056
+ if (hasExplicitIsolationAttribute (accessor->getStorage ()))
4043
4057
return true ;
4044
4058
}
4045
4059
}
0 commit comments