Skip to content

Commit b93ee4c

Browse files
committed
AST: Remove some calls to getSugaredType() which are no longer necessary
It appears that these were working around <rdar://problem/67579220>.
1 parent b0208a1 commit b93ee4c

File tree

1 file changed

+5
-44
lines changed

1 file changed

+5
-44
lines changed

lib/AST/Attr.cpp

Lines changed: 5 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -589,32 +589,11 @@ static void printDifferentiableAttrArguments(
589589
if (!isLeadingClause)
590590
stream << ' ';
591591
stream << "where ";
592-
std::function<Type(Type)> getInterfaceType;
593-
if (!original || !original->getGenericSignature()) {
594-
getInterfaceType = [](Type Ty) -> Type { return Ty; };
595-
} else {
596-
// Use GenericSignature to produce user-friendly
597-
// names instead of something like 't_0_0'.
598-
auto genericSig = original->getGenericSignature();
599-
assert(genericSig);
600-
getInterfaceType = [=](Type Ty) -> Type {
601-
return genericSig->getSugaredType(Ty);
602-
};
603-
}
604592
interleave(requirementsToPrint, [&](Requirement req) {
605593
if (const auto &originalGenSig = original->getGenericSignature())
606594
if (originalGenSig->isRequirementSatisfied(req))
607595
return;
608-
auto FirstTy = getInterfaceType(req.getFirstType());
609-
if (req.getKind() != RequirementKind::Layout) {
610-
auto SecondTy = getInterfaceType(req.getSecondType());
611-
Requirement ReqWithDecls(req.getKind(), FirstTy, SecondTy);
612-
ReqWithDecls.print(stream, Options);
613-
} else {
614-
Requirement ReqWithDecls(req.getKind(), FirstTy,
615-
req.getLayoutConstraint());
616-
ReqWithDecls.print(stream, Options);
617-
}
596+
req.print(stream, Options);
618597
}, [&] {
619598
stream << ", ";
620599
});
@@ -931,22 +910,13 @@ bool DeclAttribute::printImpl(ASTPrinter &Printer, const PrintOptions &Options,
931910
if (auto sig = attr->getSpecializedSgnature())
932911
requirements = sig->getRequirements();
933912

934-
std::function<Type(Type)> GetInterfaceType;
935913
auto *FnDecl = dyn_cast_or_null<AbstractFunctionDecl>(D);
936-
if (!FnDecl || !FnDecl->getGenericSignature())
937-
GetInterfaceType = [](Type Ty) -> Type { return Ty; };
938-
else {
939-
// Use GenericSignature to produce user-friendly
940-
// names instead of something like t_0_0.
941-
auto GenericSig = FnDecl->getGenericSignature();
942-
assert(GenericSig);
943-
GetInterfaceType = [=](Type Ty) -> Type {
944-
return GenericSig->getSugaredType(Ty);
945-
};
914+
if (FnDecl && FnDecl->getGenericSignature()) {
915+
auto genericSig = FnDecl->getGenericSignature();
946916

947917
if (auto sig = attr->getSpecializedSgnature()) {
948918
requirementsScratch = sig->requirementsNotSatisfiedBy(
949-
GenericSig);
919+
genericSig);
950920
requirements = requirementsScratch;
951921
}
952922
}
@@ -957,16 +927,7 @@ bool DeclAttribute::printImpl(ASTPrinter &Printer, const PrintOptions &Options,
957927

958928
interleave(requirements,
959929
[&](Requirement req) {
960-
auto FirstTy = GetInterfaceType(req.getFirstType());
961-
if (req.getKind() != RequirementKind::Layout) {
962-
auto SecondTy = GetInterfaceType(req.getSecondType());
963-
Requirement ReqWithDecls(req.getKind(), FirstTy, SecondTy);
964-
ReqWithDecls.print(Printer, Options);
965-
} else {
966-
Requirement ReqWithDecls(req.getKind(), FirstTy,
967-
req.getLayoutConstraint());
968-
ReqWithDecls.print(Printer, Options);
969-
}
930+
req.print(Printer, Options);
970931
},
971932
[&] { Printer << ", "; });
972933

0 commit comments

Comments
 (0)