Skip to content

Commit c530baa

Browse files
committed
AutoDiff: Clean up getOrSynthesizeTangentVectorStruct() a bit
1 parent d7339e2 commit c530baa

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

lib/Sema/DerivedConformanceDifferentiable.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -516,19 +516,13 @@ getOrSynthesizeTangentVectorStruct(DerivedConformance &derived, Identifier id) {
516516
auto *tangentEqualsSelfAlias = new (C) TypeAliasDecl(
517517
SourceLoc(), SourceLoc(), C.Id_TangentVector, SourceLoc(),
518518
/*GenericParams*/ nullptr, structDecl);
519-
tangentEqualsSelfAlias->setUnderlyingType(structDecl->getSelfTypeInContext());
520-
tangentEqualsSelfAlias->setAccess(structDecl->getFormalAccess());
519+
tangentEqualsSelfAlias->setUnderlyingType(structDecl->getDeclaredInterfaceType());
520+
tangentEqualsSelfAlias->copyFormalAccessFrom(structDecl,
521+
/*sourceIsParentContext*/ true);
521522
tangentEqualsSelfAlias->setImplicit();
522523
tangentEqualsSelfAlias->setSynthesized();
523524
structDecl->addMember(tangentEqualsSelfAlias);
524525

525-
// If nominal type is `@usableFromInline`, also mark `TangentVector` struct.
526-
if (nominal->getAttrs().hasAttribute<UsableFromInlineAttr>()) {
527-
structDecl->getAttrs().add(new (C) UsableFromInlineAttr(/*implicit*/ true));
528-
tangentEqualsSelfAlias->getAttrs().add(
529-
new (C) UsableFromInlineAttr(/*implicit*/ true));
530-
}
531-
532526
// The implicit memberwise constructor must be explicitly created so that it
533527
// can called in `AdditiveArithmetic` and `Differentiable` methods. Normally,
534528
// the memberwise constructor is synthesized during SILGen, which is too late.

0 commit comments

Comments
 (0)