Skip to content

Commit 63b2290

Browse files
authored
Merge pull request #60773 from DougGregor/strict-concurrency-fewer-deps
2 parents 013eda4 + 7d55dea commit 63b2290

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
@@ -3115,6 +3115,23 @@ swift::determineClosureActorIsolation(AbstractClosureExpr *closure) {
31153115
return checker.determineClosureIsolation(closure);
31163116
}
31173117

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+
31183135
/// Determine actor isolation solely from attributes.
31193136
///
31203137
/// \returns the actor isolation determined from attributes alone (with no
@@ -4085,8 +4102,7 @@ bool swift::contextRequiresStrictConcurrencyChecking(
40854102
} else if (auto decl = dc->getAsDecl()) {
40864103
// If any isolation attributes are present, we're using concurrency
40874104
// features.
4088-
if (getIsolationFromAttributes(
4089-
decl, /*shouldDiagnose=*/false, /*onlyExplicit=*/true))
4105+
if (hasExplicitIsolationAttribute(decl))
40904106
return true;
40914107

40924108
if (auto func = dyn_cast<AbstractFunctionDecl>(decl)) {
@@ -4097,9 +4113,7 @@ bool swift::contextRequiresStrictConcurrencyChecking(
40974113
// If we're in an accessor declaration, also check the storage
40984114
// declaration.
40994115
if (auto accessor = dyn_cast<AccessorDecl>(decl)) {
4100-
if (getIsolationFromAttributes(
4101-
accessor->getStorage(), /*shouldDiagnose=*/false,
4102-
/*onlyExplicit=*/true))
4116+
if (hasExplicitIsolationAttribute(accessor->getStorage()))
41034117
return true;
41044118
}
41054119
}

0 commit comments

Comments
 (0)