@@ -84,6 +84,11 @@ void TBDGenVisitor::addDispatchThunk(SILDeclRef declRef) {
84
84
addSymbol (entity);
85
85
}
86
86
87
+ void TBDGenVisitor::addMethodDescriptor (SILDeclRef declRef) {
88
+ auto entity = LinkEntity::forMethodDescriptor (declRef);
89
+ addSymbol (entity);
90
+ }
91
+
87
92
void TBDGenVisitor::addConformances (DeclContext *DC) {
88
93
for (auto conformance : DC->getLocalConformances ()) {
89
94
auto protocol = conformance->getProtocol ();
@@ -289,15 +294,8 @@ void TBDGenVisitor::visitClassDecl(ClassDecl *CD) {
289
294
}
290
295
291
296
// Types with resilient superclasses have some extra symbols.
292
- if (!hasResilientAncestor)
293
- return ;
294
-
295
- addSymbol (LinkEntity::forClassMetadataBaseOffset (CD));
296
-
297
- // And classes that are themselves resilient (not just a superclass) have even
298
- // more.
299
- if (!CD->isResilient ())
300
- return ;
297
+ if (hasResilientAncestor)
298
+ addSymbol (LinkEntity::forClassMetadataBaseOffset (CD));
301
299
302
300
// Emit dispatch thunks for every new vtable entry.
303
301
struct VTableVisitor : public SILVTableVisitor <VTableVisitor> {
@@ -309,8 +307,11 @@ void TBDGenVisitor::visitClassDecl(ClassDecl *CD) {
309
307
: TBD(TBD), CD(CD) {}
310
308
311
309
void addMethod (SILDeclRef method) {
312
- if (method.getDecl ()->getDeclContext () == CD)
313
- TBD.addDispatchThunk (method);
310
+ if (method.getDecl ()->getDeclContext () == CD) {
311
+ if (CD->isResilient ())
312
+ TBD.addDispatchThunk (method);
313
+ TBD.addMethodDescriptor (method);
314
+ }
314
315
}
315
316
316
317
void addMethodOverride (SILDeclRef baseRef, SILDeclRef derivedRef) {}
@@ -363,11 +364,9 @@ void TBDGenVisitor::visitProtocolDecl(ProtocolDecl *PD) {
363
364
364
365
if (PD->isResilient ()) {
365
366
for (auto *member : PD->getMembers ()) {
366
- if (auto *funcDecl = dyn_cast<FuncDecl >(member)) {
367
+ if (auto *funcDecl = dyn_cast<AbstractFunctionDecl >(member)) {
367
368
addDispatchThunk (SILDeclRef (funcDecl));
368
- }
369
- if (auto *ctorDecl = dyn_cast<ConstructorDecl>(member)) {
370
- addDispatchThunk (SILDeclRef (ctorDecl, SILDeclRef::Kind::Allocator));
369
+ addMethodDescriptor (SILDeclRef (funcDecl));
371
370
}
372
371
}
373
372
}
0 commit comments