Skip to content

Commit 7e4a43b

Browse files
authored
Merge pull request #60794 from DougGregor/strict-concurrency-fewer-deps-5.7
2 parents 0aacdfc + 2dc0909 commit 7e4a43b

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3055,6 +3055,23 @@ swift::determineClosureActorIsolation(AbstractClosureExpr *closure) {
30553055
return checker.determineClosureIsolation(closure);
30563056
}
30573057

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+
30583075
/// Determine actor isolation solely from attributes.
30593076
///
30603077
/// \returns the actor isolation determined from attributes alone (with no
@@ -4025,8 +4042,7 @@ bool swift::contextRequiresStrictConcurrencyChecking(
40254042
} else if (auto decl = dc->getAsDecl()) {
40264043
// If any isolation attributes are present, we're using concurrency
40274044
// features.
4028-
if (getIsolationFromAttributes(
4029-
decl, /*shouldDiagnose=*/false, /*onlyExplicit=*/true))
4045+
if (hasExplicitIsolationAttribute(decl))
40304046
return true;
40314047

40324048
if (auto func = dyn_cast<AbstractFunctionDecl>(decl)) {
@@ -4037,9 +4053,7 @@ bool swift::contextRequiresStrictConcurrencyChecking(
40374053
// If we're in an accessor declaration, also check the storage
40384054
// declaration.
40394055
if (auto accessor = dyn_cast<AccessorDecl>(decl)) {
4040-
if (getIsolationFromAttributes(
4041-
accessor->getStorage(), /*shouldDiagnose=*/false,
4042-
/*onlyExplicit=*/true))
4056+
if (hasExplicitIsolationAttribute(accessor->getStorage()))
40434057
return true;
40444058
}
40454059
}

0 commit comments

Comments
 (0)