Skip to content

Commit 4a91832

Browse files
committed
[Sema] RuntimeMetadata: Allow declaring init(attachedTo:) overloads in extensions
1 parent 02937a7 commit 4a91832

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/Sema/TypeCheckAttr.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7041,7 +7041,8 @@ void AttributeChecker::visitRuntimeMetadataAttr(RuntimeMetadataAttr *attr) {
70417041

70427042
// Check whether type marked as runtime attribute capable has an initializer
70437043
// with first parameter labeled as `attachedTo:`.
7044-
for (auto *member : nominal->getMembers()) {
7044+
for (auto *member :
7045+
nominal->lookupDirect(DeclBaseName::createConstructor())) {
70457046
auto *init = dyn_cast<ConstructorDecl>(member);
70467047
if (!init)
70477048
continue;

test/type/runtime_discoverable_attrs.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,15 @@ class MembersWithAvailability {
157157
func test_local_types_with_conformances() {
158158
struct X : Flagged {}
159159
}
160+
161+
@runtimeMetadata
162+
struct AttrWithInitsInExts {
163+
}
164+
165+
extension AttrWithInitsInExts {
166+
init(attachedTo: Any.Type) {}
167+
}
168+
169+
@AttrWithInitsInExts
170+
struct TestAttrWithExts { // Ok
171+
}

0 commit comments

Comments
 (0)