[Concurrency] Implement detecting isIsolatingCurrentContext user impls (#79946)

* [Concurrency] Detect non-default impls of isIsolatingCurrentContext

* [Concurrency] No need for trailing info about isIsolating... in conformance

* Apply changes from review
This commit is contained in:
Konrad `ktoso` Malawski
2025-03-18 09:39:11 +09:00
committed by GitHub
parent 1c78d0c683
commit 85fcd69833
13 changed files with 396 additions and 153 deletions

View File

@@ -2031,6 +2031,10 @@ bool ModuleDecl::isStdlibModule() const {
return !getParent() && getName() == getASTContext().StdlibModuleName;
}
bool ModuleDecl::isConcurrencyModule() const {
return !getParent() && getName() == getASTContext().Id_Concurrency;
}
bool ModuleDecl::hasStandardSubstitutions() const {
return !getParent() &&
(getName() == getASTContext().StdlibModuleName ||
@@ -4285,11 +4289,6 @@ struct SwiftSettingsWalker : ASTWalker {
} // namespace
static bool isConcurrencyModule(DeclContext *dc) {
auto *m = dc->getParentModule();
return !m->getParent() && m->getName() == m->getASTContext().Id_Concurrency;
}
bool SwiftSettingsWalker::isSwiftSettingsMacroExpr(
MacroExpansionExpr *macroExpr) {
// First make sure we actually have a macro with the name SwiftSettings.
@@ -4406,7 +4405,8 @@ SwiftSettingsWalker::patternMatchDefaultIsolationMainActor(CallExpr *callExpr) {
if (!nomDecl)
return CanType();
auto *nomDeclDC = nomDecl->getDeclContext();
if (!nomDeclDC->isModuleScopeContext() || !isConcurrencyModule(nomDeclDC))
auto *nomDeclModule = nomDecl->getParentModule();
if (!nomDeclDC->isModuleScopeContext() || !nomDeclModule->isConcurrencyModule())
return CanType();
return nomDecl->getDeclaredType()->getCanonicalType();