Skip to content

Commit 6a24820

Browse files
committed
AutoDiff: Don't synthesize TangentVector typealias alongside the TangentVector struct
1 parent a8d44bc commit 6a24820

File tree

1 file changed

+0
-31
lines changed

1 file changed

+0
-31
lines changed

lib/Sema/DerivedConformanceDifferentiable.cpp

-31
Original file line numberDiff line numberDiff line change
@@ -729,34 +729,6 @@ getOrSynthesizeTangentVectorStruct(DerivedConformance &derived, Identifier id) {
729729
return structDecl;
730730
}
731731

732-
/// Add a typealias declaration with the given name and underlying target
733-
/// struct type to the given source nominal declaration context.
734-
static void addAssociatedTypeAliasDecl(Identifier name, DeclContext *sourceDC,
735-
StructDecl *target,
736-
ASTContext &Context) {
737-
auto *nominal = sourceDC->getSelfNominalTypeDecl();
738-
assert(nominal && "Expected `DeclContext` to be a nominal type");
739-
auto lookup = nominal->lookupDirect(name);
740-
assert(lookup.size() < 2 &&
741-
"Expected at most one associated type named member");
742-
// If implicit type declaration with the given name already exists in source
743-
// struct, return it.
744-
if (lookup.size() == 1) {
745-
auto existingTypeDecl = dyn_cast<TypeDecl>(lookup.front());
746-
assert(existingTypeDecl && existingTypeDecl->isImplicit() &&
747-
"Expected lookup result to be an implicit type declaration");
748-
return;
749-
}
750-
// Otherwise, create a new typealias.
751-
auto *aliasDecl = new (Context)
752-
TypeAliasDecl(SourceLoc(), SourceLoc(), name, SourceLoc(), {}, sourceDC);
753-
aliasDecl->setUnderlyingType(target->getDeclaredInterfaceType());
754-
aliasDecl->setImplicit();
755-
aliasDecl->setGenericSignature(sourceDC->getGenericSignatureOfContext());
756-
cast<IterableDeclContext>(sourceDC->getAsDecl())->addMember(aliasDecl);
757-
aliasDecl->copyFormalAccessFrom(nominal, /*sourceIsParentContext*/ true);
758-
};
759-
760732
/// Diagnose stored properties in the nominal that do not have an explicit
761733
/// `@noDerivative` attribute, but either:
762734
/// - Do not conform to `Differentiable`.
@@ -855,9 +827,6 @@ getOrSynthesizeTangentVectorStructType(DerivedConformance &derived) {
855827
return nullptr;
856828
// Check and emit warnings for implicit `@noDerivative` members.
857829
checkAndDiagnoseImplicitNoDerivative(C, nominal, parentDC);
858-
// Add `TangentVector` typealias for `TangentVector` struct.
859-
addAssociatedTypeAliasDecl(C.Id_TangentVector, tangentStruct, tangentStruct,
860-
C);
861830

862831
// Return the `TangentVector` struct type.
863832
return parentDC->mapTypeIntoContext(

0 commit comments

Comments
 (0)