Skip to content

Commit a6a726e

Browse files
committed
[Sema] RuntimeMetadata: Make sure that attrs on unavailable extensions always have a type
1 parent 67b74a0 commit a6a726e

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lib/Sema/TypeCheckAttr.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7629,8 +7629,19 @@ GetRuntimeDiscoverableAttributes::evaluate(Evaluator &evaluator,
76297629
}
76307630

76317631
void TypeChecker::checkReflectionMetadataAttributes(ExtensionDecl *ED) {
7632+
auto &ctx = ED->getASTContext();
76327633
auto *extendedType = ED->getExtendedNominal();
76337634

7635+
// If extension has any reflection metadata attributes, trigger the
7636+
// request to set their types.
7637+
for (auto *attr : ED->getRuntimeDiscoverableAttrs()) {
7638+
(void)evaluateOrDefault(
7639+
ctx.evaluator,
7640+
CustomAttrTypeRequest{attr, ED->getDeclContext(),
7641+
CustomAttrTypeKind::RuntimeMetadata},
7642+
nullptr);
7643+
}
7644+
76347645
for (auto *protocol : ED->getLocalProtocols()) {
76357646
forEachCustomAttribute<RuntimeMetadataAttr>(
76367647
protocol, [&](CustomAttr *attr, NominalTypeDecl *attrType) {
@@ -7640,7 +7651,6 @@ void TypeChecker::checkReflectionMetadataAttributes(ExtensionDecl *ED) {
76407651
return extendedType->getRuntimeDiscoverableAttrTypeDecl(
76417652
typeAttr) == attrType;
76427653
})) {
7643-
auto &ctx = protocol->getASTContext();
76447654
ctx.Diags.diagnose(ED->getLoc(), diag::type_does_not_conform,
76457655
ED->getExtendedType(),
76467656
protocol->getDeclaredInterfaceType());

test/ModuleInterface/custom_reflection_metadata_attr.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class BaseClass {}
1818
public class TestClass : BaseClass {}
1919

2020
// CHECK: @available(*, unavailable)
21-
// CHECK-NEXT: @Flag extension CRM.TestClass {
21+
// CHECK-NEXT: @CRM.Flag extension CRM.TestClass {
2222
// CHECK-NEXT: }
2323

2424
@available(*, unavailable)

0 commit comments

Comments
 (0)