Skip to content

Commit be4ac2c

Browse files
committed
Don’t use isRequirementSignatureComputed because it is lazy
1 parent 3dd54c2 commit be4ac2c

File tree

4 files changed

+5
-43
lines changed

4 files changed

+5
-43
lines changed

lib/AST/ASTPrinter.cpp

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,7 +1269,6 @@ bestRequirementPrintLocation(ProtocolDecl *proto, const Requirement &req) {
12691269

12701270
void PrintAST::printInheritedFromRequirementSignature(ProtocolDecl *proto,
12711271
Decl *attachingTo) {
1272-
assert(proto->isRequirementSignatureComputed());
12731272
printGenericSignature(
12741273
GenericSignature::get({proto->getProtocolSelfType()} ,
12751274
proto->getRequirementSignature()),
@@ -1282,7 +1281,6 @@ void PrintAST::printInheritedFromRequirementSignature(ProtocolDecl *proto,
12821281

12831282
void PrintAST::printWhereClauseFromRequirementSignature(ProtocolDecl *proto,
12841283
Decl *attachingTo) {
1285-
assert(proto->isRequirementSignatureComputed());
12861284
unsigned flags = PrintRequirements;
12871285
if (isa<AssociatedTypeDecl>(attachingTo))
12881286
flags |= SwapSelfAndDependentMemberType;
@@ -2316,11 +2314,7 @@ void PrintAST::visitAssociatedTypeDecl(AssociatedTypeDecl *decl) {
23162314
});
23172315

23182316
auto proto = decl->getProtocol();
2319-
if (proto->isRequirementSignatureComputed()) {
2320-
printInheritedFromRequirementSignature(proto, decl);
2321-
} else {
2322-
printInherited(decl);
2323-
}
2317+
printInheritedFromRequirementSignature(proto, decl);
23242318

23252319
if (decl->hasDefaultDefinitionType()) {
23262320
Printer << " = ";
@@ -2329,13 +2323,7 @@ void PrintAST::visitAssociatedTypeDecl(AssociatedTypeDecl *decl) {
23292323

23302324
// As with protocol's trailing where clauses, use the requirement signature
23312325
// when available.
2332-
if (proto->isRequirementSignatureComputed()) {
2333-
printWhereClauseFromRequirementSignature(proto, decl);
2334-
} else {
2335-
if (auto trailingWhere = decl->getTrailingWhereClause()) {
2336-
printTrailingWhereClause(trailingWhere);
2337-
}
2338-
}
2326+
printWhereClauseFromRequirementSignature(proto, decl);
23392327
}
23402328

23412329
void PrintAST::visitEnumDecl(EnumDecl *decl) {
@@ -2442,23 +2430,13 @@ void PrintAST::visitProtocolDecl(ProtocolDecl *decl) {
24422430
Printer.printName(decl->getName());
24432431
});
24442432

2445-
if (decl->isRequirementSignatureComputed()) {
2446-
printInheritedFromRequirementSignature(decl, decl);
2447-
} else {
2448-
printInherited(decl);
2449-
}
2433+
printInheritedFromRequirementSignature(decl, decl);
24502434

24512435
// The trailing where clause is a syntactic thing, which isn't serialized
24522436
// (etc.) and thus isn't available for printing things out of
24532437
// already-compiled SIL modules. The requirement signature is available in
24542438
// such cases, so let's go with that when we can.
2455-
if (decl->isRequirementSignatureComputed()) {
2456-
printWhereClauseFromRequirementSignature(decl, decl);
2457-
} else {
2458-
if (auto trailingWhere = decl->getTrailingWhereClause()) {
2459-
printTrailingWhereClause(trailingWhere);
2460-
}
2461-
}
2439+
printWhereClauseFromRequirementSignature(decl, decl);
24622440
}
24632441
if (Options.TypeDefinitions) {
24642442
printMembersOfDecl(decl, false, true,

lib/Sema/TypeCheckDecl.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4527,9 +4527,7 @@ static void finalizeType(TypeChecker &TC, NominalTypeDecl *nominal) {
45274527
// like the requirement signature have been set.
45284528
if (auto PD = dyn_cast<ProtocolDecl>(nominal)) {
45294529
(void)PD->getInheritedProtocols();
4530-
if (!PD->isRequirementSignatureComputed()) {
4531-
TC.validateDecl(PD);
4532-
}
4530+
TC.validateDecl(PD);
45334531
}
45344532
}
45354533

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3475,11 +3475,6 @@ ResolveWitnessResult ConformanceChecker::resolveTypeWitnessViaLookup(
34753475
abort();
34763476
}
34773477

3478-
if (!Proto->isRequirementSignatureComputed()) {
3479-
Conformance->setInvalid();
3480-
return ResolveWitnessResult::Missing;
3481-
}
3482-
34833478
// Look for a member type with the same name as the associated type.
34843479
auto candidates = TC.lookupMemberType(DC, Adoptee, assocType->getName(),
34853480
NameLookupFlags::ProtocolMembers);
@@ -3629,11 +3624,6 @@ void ConformanceChecker::addUsedConformances(ProtocolConformance *conformance) {
36293624
void ConformanceChecker::ensureRequirementsAreSatisfied(
36303625
bool failUnsubstituted) {
36313626
auto proto = Conformance->getProtocol();
3632-
// Some other problem stopped the signature being computed.
3633-
if (!proto->isRequirementSignatureComputed()) {
3634-
Conformance->setInvalid();
3635-
return;
3636-
}
36373627

36383628
if (CheckedRequirementSignature)
36393629
return;

lib/Sema/TypeCheckProtocolInference.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,10 +1095,6 @@ AssociatedTypeInference::getSubstOptionsWithCurrentTypeWitnesses() {
10951095
bool AssociatedTypeInference::checkCurrentTypeWitnesses(
10961096
const SmallVectorImpl<std::pair<ValueDecl *, ValueDecl *>>
10971097
&valueWitnesses) {
1098-
// If we don't have a requirement signature for this protocol, bail out.
1099-
// FIXME: We should never get to this point. Or we should always fail.
1100-
if (!proto->isRequirementSignatureComputed()) return false;
1101-
11021098
// Check any same-type requirements in the protocol's requirement signature.
11031099
SubstOptions options = getSubstOptionsWithCurrentTypeWitnesses();
11041100

0 commit comments

Comments
 (0)