Skip to content

Commit 43904e5

Browse files
committed
[ASTPrinter] Mark declarations with runtime attributes as using the feature
1 parent 11033c6 commit 43904e5

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

lib/AST/ASTPrinter.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -2963,7 +2963,13 @@ static bool usesFeatureTypeWrappers(Decl *decl) {
29632963
}
29642964

29652965
static bool usesFeatureRuntimeDiscoverableAttrs(Decl *decl) {
2966-
return decl->getAttrs().hasAttribute<RuntimeMetadataAttr>();
2966+
if (decl->getAttrs().hasAttribute<RuntimeMetadataAttr>())
2967+
return true;
2968+
2969+
if (auto *VD = dyn_cast<ValueDecl>(decl))
2970+
return !VD->getRuntimeDiscoverableAttrs().empty();
2971+
2972+
return false;
29672973
}
29682974

29692975
static bool usesFeatureParserRoundTrip(Decl *decl) {

lib/AST/Decl.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -9702,3 +9702,10 @@ ValueDecl::getRuntimeDiscoverableAttrTypeDecl(CustomAttr *attr) const {
97029702
assert(nominal->getAttrs().hasAttribute<RuntimeMetadataAttr>());
97039703
return nominal;
97049704
}
9705+
9706+
ArrayRef<CustomAttr *> ValueDecl::getRuntimeDiscoverableAttrs() const {
9707+
auto *mutableSelf = const_cast<ValueDecl *>(this);
9708+
return evaluateOrDefault(getASTContext().evaluator,
9709+
GetRuntimeDiscoverableAttributes{mutableSelf},
9710+
nullptr);
9711+
}

lib/Sema/TypeCheckRuntimeMetadataAttr.cpp

-7
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,6 @@
2929
using namespace swift;
3030
using namespace constraints;
3131

32-
ArrayRef<CustomAttr *> ValueDecl::getRuntimeDiscoverableAttrs() const {
33-
auto *mutableSelf = const_cast<ValueDecl *>(this);
34-
return evaluateOrDefault(getASTContext().evaluator,
35-
GetRuntimeDiscoverableAttributes{mutableSelf},
36-
nullptr);
37-
}
38-
3932
std::pair<BraceStmt *, Type>
4033
ValueDecl::getRuntimeDiscoverableAttributeGenerator(CustomAttr *attr) const {
4134
auto *mutableSelf = const_cast<ValueDecl *>(this);

0 commit comments

Comments
 (0)