@@ -146,11 +146,12 @@ template <class T> class SILWitnessVisitor : public ASTVisitor<T> {
146146
147147 void visitFuncDecl (FuncDecl *func) {
148148 assert (!isa<AccessorDecl>(func));
149- if (func->requiresNewWitnessTableEntry ()) {
150- asDerived ().addMethod (SILDeclRef (func, SILDeclRef::Kind::Func));
151- addAutoDiffDerivativeMethodsIfRequired (func, SILDeclRef::Kind::Func);
152- addDistributedWitnessMethodsIfRequired (func, SILDeclRef::Kind::Func);
153- }
149+ if (!func->requiresNewWitnessTableEntry ())
150+ return ;
151+
152+ asDerived ().addMethod (SILDeclRef (func, SILDeclRef::Kind::Func));
153+ addAutoDiffDerivativeMethodsIfRequired (func, SILDeclRef::Kind::Func);
154+ addDistributedWitnessMethodsIfRequired (func, SILDeclRef::Kind::Func);
154155 }
155156
156157 void visitMissingMemberDecl (MissingMemberDecl *placeholder) {
@@ -160,7 +161,7 @@ template <class T> class SILWitnessVisitor : public ASTVisitor<T> {
160161 void visitAssociatedTypeDecl (AssociatedTypeDecl *td) {
161162 // We already visited these in the first pass.
162163 }
163-
164+
164165 void visitTypeAliasDecl (TypeAliasDecl *tad) {
165166 // We don't care about these by themselves for witnesses.
166167 }
@@ -200,11 +201,11 @@ template <class T> class SILWitnessVisitor : public ASTVisitor<T> {
200201
201202 void addDistributedWitnessMethodsIfRequired (AbstractFunctionDecl *AFD,
202203 SILDeclRef::Kind kind) {
203- if (!AFD->isDistributed ())
204+ if (!AFD || !AFD ->isDistributed ())
204205 return ;
205206
206- // Add another which will be witnessed by the 'distributed thunk'
207- SILDeclRef declRef (AFD , kind);
207+ auto thunk = AFD-> getDistributedThunk ();
208+ SILDeclRef declRef (thunk , kind);
208209 asDerived ().addMethod (declRef.asDistributed ());
209210 }
210211};
0 commit comments