mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[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:
@@ -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
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user