Skip to content

Commit 0e7e110

Browse files
committed
[Sema] Add skeleton implementation of @runtimeMetadata attribute
Use of the attribute is gated on `RuntimeDiscoverableAttrs` flag.
1 parent a6427ca commit 0e7e110

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6756,6 +6756,14 @@ ERROR(moveonly_cannot_conform_to_protocol, none,
67566756
ERROR(moveonly_cannot_conform_to_protocol_with_name, none,
67576757
"move-only %0 %1 cannot conform to protocol %2",
67586758
(DescriptiveDeclKind, DeclName, DeclName))
6759+
6760+
//------------------------------------------------------------------------------
6761+
// MARK: Runtime discoverable attributes (@runtimeMetadata)
6762+
//------------------------------------------------------------------------------
6763+
6764+
ERROR(runtime_discoverable_attrs_are_experimental,none,
6765+
"runtime discoverable attributes are an experimental feature", ())
6766+
67596767
#define UNDEFINE_DIAGNOSTIC_MACROS
67606768
#include "DefineDiagnosticMacros.h"
67616769

lib/Sema/TypeCheckAttr.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,8 @@ class AttributeChecker : public AttributeVisitor<AttributeChecker> {
336336
void visitKnownToBeLocalAttr(KnownToBeLocalAttr *attr);
337337

338338
void visitSendableAttr(SendableAttr *attr);
339+
340+
void visitRuntimeMetadataAttr(RuntimeMetadataAttr *attr);
339341
};
340342

341343
} // end anonymous namespace
@@ -6934,6 +6936,15 @@ void AttributeChecker::visitCompilerInitializedAttr(
69346936
}
69356937
}
69366938

6939+
void AttributeChecker::visitRuntimeMetadataAttr(RuntimeMetadataAttr *attr) {
6940+
if (!Ctx.LangOpts.hasFeature(Feature::RuntimeDiscoverableAttrs)) {
6941+
diagnose(attr->getLocation(),
6942+
diag::runtime_discoverable_attrs_are_experimental);
6943+
attr->setInvalid();
6944+
return;
6945+
}
6946+
}
6947+
69376948
namespace {
69386949

69396950
class ClosureAttributeChecker

lib/Sema/TypeCheckDeclOverride.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,6 +1623,8 @@ namespace {
16231623

16241624
UNINTERESTING_ATTR(EagerMove)
16251625
UNINTERESTING_ATTR(NoEagerMove)
1626+
1627+
UNINTERESTING_ATTR(RuntimeMetadata)
16261628
#undef UNINTERESTING_ATTR
16271629

16281630
void visitAvailableAttr(AvailableAttr *attr) {

0 commit comments

Comments
 (0)