Skip to content

Commit 7839ab6

Browse files
committed
AutoDiff: Synthesize the memberwise initializer earlier
We need to do this before we synthesize the body of the AdditiveArithmetic witnesses, so that it becomes part of the ABI members of the nominal.
1 parent f6b191b commit 7839ab6

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lib/Sema/DerivedConformanceAdditiveArithmetic.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,12 @@ static ValueDecl *deriveMathOperator(DerivedConformance &derived,
207207
operatorDecl->copyFormalAccessFrom(nominal, /*sourceIsParentContext*/ true);
208208

209209
derived.addMembersToConformanceContext({operatorDecl});
210+
211+
// For the effective memberwise initializer before we force the body,
212+
// so that it becomes part of the emitted ABI members even if we don't
213+
// emit the body.
214+
(void) nominal->getEffectiveMemberwiseInitializer();
215+
210216
return operatorDecl;
211217
}
212218

@@ -311,6 +317,12 @@ static ValueDecl *deriveAdditiveArithmetic_zero(DerivedConformance &derived) {
311317
getterDecl->setBodySynthesizer(deriveBodyAdditiveArithmetic_zero, nullptr);
312318

313319
derived.addMembersToConformanceContext({propDecl, pbDecl});
320+
321+
// For the effective memberwise initializer before we force the body,
322+
// so that it becomes part of the emitted ABI members even if we don't
323+
// emit the body.
324+
(void) nominal->getEffectiveMemberwiseInitializer();
325+
314326
return propDecl;
315327
}
316328

0 commit comments

Comments
 (0)