Skip to content

Commit 8992ea8

Browse files
Merge pull request #85433 from swiftlang/jepa-main4
AST: Rename `GenericContext::isGeneric` to `hasGenericParamList`
2 parents 2002b90 + bda6edb commit 8992ea8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+106
-101
lines changed

docs/Generics/chapters/declarations.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,7 @@ \subsection*{Generic Contexts}
10491049
\begin{itemize}
10501050
\item \texttt{getParsedGenericParams()} returns the declaration's parsed generic parameter list, or \texttt{nullptr}.
10511051
\item \texttt{getGenericParams()} returns the declaration's full generic parameter list, which includes any implicit generic parameters. Evaluates a \texttt{GenericParamListRequest}.
1052-
\item \texttt{isGeneric()} answers if this declaration has a generic parameter list. This is equivalent to calling \texttt{DeclContext::isInnermostContextGeneric()}. Compare with \texttt{DeclContext::isGenericContext()}.
1052+
\item \texttt{hasGenericParamList()} answers if this declaration has a generic parameter list. This is equivalent to calling \texttt{isInnermostContextGeneric()} on \texttt{DeclContext}. Compare with \texttt{DeclContext::isGenericContext()}.
10531053
\item \texttt{getGenericContextDepth()} returns the \IndexSource{depth}depth of the declaration's generic parameter list, or \texttt{(unsigned)-1} if neither this declaration nor any outer declaration is generic.
10541054
\item \texttt{getTrailingWhereClause()} returns the declaration's trailing \texttt{where} clause, or \texttt{nullptr}.
10551055
\end{itemize}

include/swift/AST/Decl.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,15 +1696,15 @@ class GenericContext : private _GenericContext, public DeclContext {
16961696
///
16971697
/// \code
16981698
/// class C<T> {
1699-
/// func f1() {} // isGeneric == false
1700-
/// func f2<T>() {} // isGeneric == true
1699+
/// func f1() {} // hasGenericParamList == false
1700+
/// func f2<T>() {} // hasGenericParamList == true
17011701
/// }
17021702
///
1703-
/// protocol P { // isGeneric == true due to implicit Self param
1704-
/// func p() // isGeneric == false
1703+
/// protocol P { // hasGenericParamList == true due to implicit Self param
1704+
/// func p() // hasGenericParamList == false
17051705
/// }
17061706
/// \endcode
1707-
bool isGeneric() const { return getGenericParams() != nullptr; }
1707+
bool hasGenericParamList() const { return getGenericParams() != nullptr; }
17081708
bool hasComputedGenericSignature() const;
17091709
bool isComputingGenericSignature() const;
17101710

lib/AST/ASTContext.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6893,10 +6893,10 @@ bool ASTContext::overrideGenericSignatureReqsSatisfied(
68936893
auto *baseCtx = base->getAsGenericContext();
68946894
auto *derivedCtx = derived->getAsGenericContext();
68956895

6896-
if (baseCtx->isGeneric() != derivedCtx->isGeneric())
6896+
if (baseCtx->hasGenericParamList() != derivedCtx->hasGenericParamList())
68976897
return false;
68986898

6899-
if (baseCtx->isGeneric() &&
6899+
if (baseCtx->hasGenericParamList() &&
69006900
(baseCtx->getGenericParams()->size() !=
69016901
derivedCtx->getGenericParams()->size()))
69026902
return false;

lib/AST/ASTDemangler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ Type ASTBuilder::createNominalType(GenericTypeDecl *decl, Type parent) {
281281
return Type();
282282

283283
// If the declaration is generic, fail.
284-
if (nominalDecl->isGeneric())
284+
if (nominalDecl->hasGenericParamList())
285285
return Type();
286286

287287
// Imported types can be renamed to be members of other (non-generic)

lib/AST/ASTMangler.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2008,9 +2008,10 @@ unsigned ASTMangler::appendBoundGenericArgs(DeclContext *dc,
20082008
// type declaration are not part of the mangling, so check whether the
20092009
// naming declaration has generic parameters.
20102010
auto namedGenericContext = opaque->getNamingDecl()->getAsGenericContext();
2011-
treatAsGeneric = namedGenericContext && namedGenericContext->isGeneric();
2011+
treatAsGeneric =
2012+
namedGenericContext && namedGenericContext->hasGenericParamList();
20122013
} else {
2013-
treatAsGeneric = genericContext->isGeneric();
2014+
treatAsGeneric = genericContext->hasGenericParamList();
20142015
}
20152016
if (treatAsGeneric) {
20162017
auto genericParams = subs.getGenericSignature().getGenericParams();
@@ -5430,7 +5431,7 @@ static std::optional<unsigned> getEnclosingTypeGenericDepth(const Decl *decl) {
54305431
if (!typeDecl)
54315432
return std::nullopt;
54325433

5433-
if (!typeDecl->isGeneric())
5434+
if (!typeDecl->hasGenericParamList())
54345435
return std::nullopt;
54355436

54365437
return typeDecl->getGenericSignature()->getMaxDepth();

lib/AST/ASTPrinter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2961,7 +2961,7 @@ void PrintAST::printMembers(ArrayRef<Decl *> members, bool needComma,
29612961
}
29622962

29632963
void PrintAST::printGenericDeclGenericParams(GenericContext *decl) {
2964-
if (decl->isGeneric())
2964+
if (decl->hasGenericParamList())
29652965
if (auto GenericSig = decl->getGenericSignature()) {
29662966
Printer.printStructurePre(PrintStructureKind::DeclGenericParameterClause);
29672967
printGenericSignature(GenericSig, PrintParams | InnermostOnly);
@@ -6364,7 +6364,7 @@ class TypePrinter : public TypeVisitor<TypePrinter, void, NonRecursivePrintOptio
63646364
printQualifiedType(T);
63656365

63666366
auto *typeAliasDecl = T->getDecl();
6367-
if (typeAliasDecl->isGeneric()) {
6367+
if (typeAliasDecl->hasGenericParamList()) {
63686368
if (Options.PrintTypesForDebugging)
63696369
printGenericArgs(T->getDirectGenericArgs());
63706370
else

lib/AST/ASTVerifier.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3239,7 +3239,7 @@ class Verifier : public ASTWalker {
32393239
void verifyParsed(DestructorDecl *DD) {
32403240
PrettyStackTraceDecl debugStack("verifying DestructorDecl", DD);
32413241

3242-
if (DD->isGeneric()) {
3242+
if (DD->hasGenericParamList()) {
32433243
Out << "DestructorDecl cannot be generic";
32443244
abort();
32453245
}

lib/AST/Decl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4250,7 +4250,7 @@ OverloadSignature ValueDecl::getOverloadSignature() const {
42504250
}
42514251

42524252
if (auto *extension = dyn_cast<ExtensionDecl>(getDeclContext()))
4253-
if (extension->isGeneric())
4253+
if (extension->hasGenericParamList())
42544254
signature.InExtensionOfGenericType = true;
42554255

42564256
return signature;

lib/AST/DeclContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ swift::FragileFunctionKindRequest::evaluate(Evaluator &evaluator,
629629
bool DeclContext::isInnermostContextGeneric() const {
630630
if (auto Decl = getAsDecl())
631631
if (auto GC = Decl->getAsGenericContext())
632-
return GC->isGeneric();
632+
return GC->hasGenericParamList();
633633
return false;
634634
}
635635

lib/AST/DistributedDecl.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ bool AbstractFunctionDecl::isDistributedActorSystemRemoteCall(bool isVoidReturn)
467467
auto &C = getASTContext();
468468
auto *DC = getDeclContext();
469469

470-
if (!DC->isTypeContext() || !isGeneric())
470+
if (!DC->isTypeContext() || !hasGenericParamList())
471471
return false;
472472

473473
// === Check the name
@@ -512,7 +512,7 @@ bool AbstractFunctionDecl::isDistributedActorSystemRemoteCall(bool isVoidReturn)
512512
}
513513

514514
// === Check generics
515-
if (!isGeneric()) {
515+
if (!hasGenericParamList()) {
516516
return false;
517517
}
518518

@@ -809,7 +809,7 @@ AbstractFunctionDecl::isDistributedTargetInvocationEncoderRecordArgument() const
809809
}
810810

811811
// === Check generics
812-
if (!isGeneric()) {
812+
if (!hasGenericParamList()) {
813813
return false;
814814
}
815815

@@ -949,7 +949,7 @@ AbstractFunctionDecl::isDistributedTargetInvocationEncoderRecordReturnType() con
949949
}
950950

951951
// === Check generics
952-
if (!isGeneric()) {
952+
if (!hasGenericParamList()) {
953953
return false;
954954
}
955955

@@ -1078,7 +1078,7 @@ AbstractFunctionDecl::isDistributedTargetInvocationEncoderRecordErrorType() cons
10781078
}
10791079

10801080
// === Check generics
1081-
if (!isGeneric()) {
1081+
if (!hasGenericParamList()) {
10821082
return false;
10831083
}
10841084

@@ -1188,7 +1188,7 @@ AbstractFunctionDecl::isDistributedTargetInvocationDecoderDecodeNextArgument() c
11881188

11891189

11901190
// === Check generics
1191-
if (!isGeneric()) {
1191+
if (!hasGenericParamList()) {
11921192
return false;
11931193
}
11941194

@@ -1282,7 +1282,7 @@ AbstractFunctionDecl::isDistributedTargetInvocationResultHandlerOnReturn() const
12821282
}
12831283

12841284
// === Check generics
1285-
if (!isGeneric()) {
1285+
if (!hasGenericParamList()) {
12861286
return false;
12871287
}
12881288

0 commit comments

Comments
 (0)