Skip to content

Commit bc4aa75

Browse files
committed
AST: Simplify GenericSignatureBuilder::computeRequirementSignature()
1 parent a90d8a8 commit bc4aa75

File tree

2 files changed

+4
-19
lines changed

2 files changed

+4
-19
lines changed

lib/AST/Decl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4282,7 +4282,7 @@ void ProtocolDecl::createGenericParamsIfMissing() {
42824282
auto selfDecl = new (ctx) GenericTypeParamDecl(
42834283
this, selfId,
42844284
SourceLoc(),
4285-
GenericTypeParamDecl::InvalidDepth, /*index=*/0);
4285+
/*depth=*/getGenericContextDepth() + 1, /*index=*/0);
42864286
auto protoType = getDeclaredType();
42874287
TypeLoc selfInherited[1] = { TypeLoc::withoutLoc(protoType) };
42884288
selfDecl->setInherited(ctx.AllocateCopy(selfInherited));

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7490,29 +7490,14 @@ GenericSignature *GenericSignatureBuilder::computeGenericSignature(
74907490
return sig;
74917491
}
74927492

7493-
/// Add all of the generic parameters from the given parameter list (and it's
7494-
/// outer generic parameter lists) to the given generic signature builder.
7495-
static void addAllGenericParams(GenericSignatureBuilder &builder,
7496-
GenericParamList *genericParams) {
7497-
if (!genericParams) return;
7498-
7499-
addAllGenericParams(builder, genericParams->getOuterParameters());
7500-
for (auto gp : *genericParams)
7501-
builder.addGenericParameter(gp);
7502-
}
7503-
75047493
GenericSignature *GenericSignatureBuilder::computeRequirementSignature(
75057494
ProtocolDecl *proto) {
75067495
GenericSignatureBuilder builder(proto->getASTContext());
75077496

7508-
if (!proto->hasInterfaceType()) {
7509-
// FIXME: Overkill.
7510-
if (auto lazyResolver = proto->getASTContext().getLazyResolver())
7511-
lazyResolver->resolveDeclSignature(proto);
7512-
}
7513-
75147497
// Add all of the generic parameters.
7515-
addAllGenericParams(builder, proto->getGenericParams());
7498+
proto->createGenericParamsIfMissing();
7499+
for (auto gp : *proto->getGenericParams())
7500+
builder.addGenericParameter(gp);
75167501

75177502
// Add the conformance of 'self' to the protocol.
75187503
auto selfType =

0 commit comments

Comments
 (0)