Skip to content

Commit c0bfaaf

Browse files
committed
AST: Merge ProtocolDecl::createGenericParams() into createGenericParamsIfMissing()
1 parent 7a038ff commit c0bfaaf

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

include/swift/AST/Decl.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4107,10 +4107,6 @@ class ProtocolDecl final : public NominalTypeDecl {
41074107
/// with the Objective-C runtime.
41084108
StringRef getObjCRuntimeName(llvm::SmallVectorImpl<char> &buffer) const;
41094109

4110-
/// Create the implicit generic parameter list for a protocol or
4111-
/// extension thereof.
4112-
GenericParamList *createGenericParams(DeclContext *dc);
4113-
41144110
/// Create the generic parameters of this protocol if the haven't been
41154111
/// created yet.
41164112
void createGenericParamsIfMissing();

lib/AST/Decl.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4297,14 +4297,17 @@ StringRef ProtocolDecl::getObjCRuntimeName(
42974297
return mangleObjCRuntimeName(this, buffer);
42984298
}
42994299

4300-
GenericParamList *ProtocolDecl::createGenericParams(DeclContext *dc) {
4300+
void ProtocolDecl::createGenericParamsIfMissing() {
4301+
if (getGenericParams())
4302+
return;
4303+
43014304
auto *outerGenericParams = getParent()->getGenericParamsOfContext();
43024305

43034306
// The generic parameter 'Self'.
43044307
auto &ctx = getASTContext();
43054308
auto selfId = ctx.Id_Self;
43064309
auto selfDecl = new (ctx) GenericTypeParamDecl(
4307-
dc, selfId,
4310+
this, selfId,
43084311
SourceLoc(),
43094312
GenericTypeParamDecl::InvalidDepth, /*index=*/0);
43104313
auto protoType = getDeclaredType();
@@ -4316,12 +4319,7 @@ GenericParamList *ProtocolDecl::createGenericParams(DeclContext *dc) {
43164319
auto result = GenericParamList::create(ctx, SourceLoc(), selfDecl,
43174320
SourceLoc());
43184321
result->setOuterParameters(outerGenericParams);
4319-
return result;
4320-
}
4321-
4322-
void ProtocolDecl::createGenericParamsIfMissing() {
4323-
if (!getGenericParams())
4324-
setGenericParams(createGenericParams(this));
4322+
setGenericParams(result);
43254323
}
43264324

43274325
void ProtocolDecl::computeRequirementSignature() {

lib/ClangImporter/ImportDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8053,7 +8053,7 @@ ClangImporter::Implementation::importDeclContextOf(
80538053
ext->setMemberLoader(this, reinterpret_cast<uintptr_t>(declSubmodule));
80548054

80558055
if (auto protoDecl = ext->getExtendedProtocolDecl()) {
8056-
ext->setGenericParams(protoDecl->createGenericParams(ext));
8056+
ext->createGenericParamsIfMissing(protoDecl);
80578057

80588058
auto *env = buildGenericEnvironment(ext->getGenericParams(), ext);
80598059
ext->setGenericEnvironment(env);

0 commit comments

Comments
 (0)