[Frontend] Hide @execution attribute behind an experimental feature ExecutionAttribute

Since the proposal has not been approved yet we cannot expose
`@execution` attribute.
This commit is contained in:
Pavel Yaskevich
2025-02-19 19:53:19 -08:00
parent e2ff3308be
commit dd1be8f6d4
19 changed files with 144 additions and 18 deletions

View File

@@ -416,6 +416,45 @@ static bool usesFeatureBuiltinEmplaceTypedThrows(Decl *decl) {
return false;
}
static bool usesFeatureExecutionAttribute(Decl *decl) {
if (decl->getAttrs().hasAttribute<ExecutionAttr>())
return true;
auto VD = dyn_cast<ValueDecl>(decl);
if (!VD)
return false;
auto hasExecutionAttr = [](TypeRepr *R) {
if (!R)
return false;
return R->findIf([](TypeRepr *repr) {
if (auto *AT = dyn_cast<AttributedTypeRepr>(repr)) {
return llvm::any_of(AT->getAttrs(), [](TypeOrCustomAttr attr) {
if (auto *TA = attr.dyn_cast<TypeAttribute *>()) {
return isa<ExecutionTypeAttr>(TA);
}
return false;
});
}
return false;
});
};
// Check if any parameters that have `@execution` attribute.
if (auto *PL = getParameterList(VD)) {
for (auto *P : *PL) {
if (hasExecutionAttr(P->getTypeRepr()))
return true;
}
}
if (hasExecutionAttr(VD->getResultTypeRepr()))
return true;
return false;
}
// ----------------------------------------------------------------------------
// MARK: - FeatureSet
// ----------------------------------------------------------------------------