Skip to content

Commit 36b3f0e

Browse files
committed
AST: Remove AbstractTypeParamDecl
1 parent 0e4ccb2 commit 36b3f0e

File tree

6 files changed

+16
-37
lines changed

6 files changed

+16
-37
lines changed

include/swift/AST/Decl.h

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -499,9 +499,8 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl> {
499499
);
500500

501501
SWIFT_INLINE_BITFIELD_EMPTY(TypeDecl, ValueDecl);
502-
SWIFT_INLINE_BITFIELD_EMPTY(AbstractTypeParamDecl, TypeDecl);
503502

504-
SWIFT_INLINE_BITFIELD_FULL(GenericTypeParamDecl, AbstractTypeParamDecl, 16+16+1+1,
503+
SWIFT_INLINE_BITFIELD_FULL(GenericTypeParamDecl, TypeDecl, 16+16+1+1,
505504
: NumPadBits,
506505

507506
Depth : 16,
@@ -3182,22 +3181,6 @@ class TypeAliasDecl : public GenericTypeDecl {
31823181
}
31833182
};
31843183

3185-
/// Abstract class describing generic type parameters and associated types,
3186-
/// whose common purpose is to anchor the abstract type parameter and specify
3187-
/// requirements for any corresponding type argument.
3188-
class AbstractTypeParamDecl : public TypeDecl {
3189-
protected:
3190-
AbstractTypeParamDecl(DeclKind kind, DeclContext *dc, Identifier name,
3191-
SourceLoc NameLoc)
3192-
: TypeDecl(kind, dc, name, NameLoc, { }) { }
3193-
3194-
public:
3195-
static bool classof(const Decl *D) {
3196-
return D->getKind() >= DeclKind::First_AbstractTypeParamDecl &&
3197-
D->getKind() <= DeclKind::Last_AbstractTypeParamDecl;
3198-
}
3199-
};
3200-
32013184
/// A declaration of a generic type parameter.
32023185
///
32033186
/// A generic type parameter introduces a new, named type parameter along
@@ -3212,7 +3195,7 @@ class AbstractTypeParamDecl : public TypeDecl {
32123195
/// func min<T : Comparable>(x : T, y : T) -> T { ... }
32133196
/// \endcode
32143197
class GenericTypeParamDecl final
3215-
: public AbstractTypeParamDecl,
3198+
: public TypeDecl,
32163199
private llvm::TrailingObjects<GenericTypeParamDecl, TypeRepr *,
32173200
SourceLoc> {
32183201
friend TrailingObjects;
@@ -3439,7 +3422,7 @@ class GenericTypeParamDecl final
34393422
/// func getNext() -> Element?
34403423
/// }
34413424
/// \endcode
3442-
class AssociatedTypeDecl : public AbstractTypeParamDecl {
3425+
class AssociatedTypeDecl : public TypeDecl {
34433426
/// The location of the initial keyword.
34443427
SourceLoc KeywordLoc;
34453428

include/swift/AST/DeclNodes.def

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,8 @@ ABSTRACT_DECL(Value, Decl)
156156
GENERIC_VALUE_DECL(OpaqueType, GenericTypeDecl)
157157
GENERIC_VALUE_DECL(TypeAlias, GenericTypeDecl)
158158
DECL_RANGE(GenericType, Enum, TypeAlias)
159-
ABSTRACT_DECL(AbstractTypeParam, TypeDecl)
160-
VALUE_DECL(GenericTypeParam, AbstractTypeParamDecl)
161-
VALUE_DECL(AssociatedType, AbstractTypeParamDecl)
162-
DECL_RANGE(AbstractTypeParam, GenericTypeParam, AssociatedType)
159+
VALUE_DECL(GenericTypeParam, TypeDecl)
160+
VALUE_DECL(AssociatedType, TypeDecl)
163161
CONTEXT_VALUE_DECL(Module, TypeDecl)
164162
DECL_RANGE(Type, Enum, Module)
165163
ABSTRACT_DECL(AbstractStorage, ValueDecl)

lib/AST/ASTDumper.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -648,19 +648,14 @@ namespace {
648648
PrintWithColorRAII(OS, ParenthesisColor) << ')';
649649
}
650650

651-
void printAbstractTypeParamCommon(AbstractTypeParamDecl *decl,
652-
const char *name) {
653-
printCommon(decl, name);
654-
}
655-
656651
void visitGenericTypeParamDecl(GenericTypeParamDecl *decl) {
657-
printAbstractTypeParamCommon(decl, "generic_type_param");
652+
printCommon(decl, "generic_type_param");
658653
OS << " depth=" << decl->getDepth() << " index=" << decl->getIndex();
659654
PrintWithColorRAII(OS, ParenthesisColor) << ')';
660655
}
661656

662657
void visitAssociatedTypeDecl(AssociatedTypeDecl *decl) {
663-
printAbstractTypeParamCommon(decl, "associated_type_decl");
658+
printCommon(decl, "associated_type_decl");
664659
if (auto defaultDef = decl->getDefaultDefinitionType()) {
665660
OS << " default=";
666661
defaultDef.print(OS);

lib/AST/Decl.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4627,7 +4627,7 @@ GenericTypeParamDecl::GenericTypeParamDecl(
46274627
DeclContext *dc, Identifier name, SourceLoc nameLoc, SourceLoc ellipsisLoc,
46284628
unsigned depth, unsigned index, bool isParameterPack, bool isOpaqueType,
46294629
TypeRepr *opaqueTypeRepr)
4630-
: AbstractTypeParamDecl(DeclKind::GenericTypeParam, dc, name, nameLoc) {
4630+
: TypeDecl(DeclKind::GenericTypeParam, dc, name, nameLoc, { }) {
46314631
assert(!(ellipsisLoc && !isParameterPack) &&
46324632
"Ellipsis always means type parameter pack");
46334633

@@ -4711,7 +4711,7 @@ AssociatedTypeDecl::AssociatedTypeDecl(DeclContext *dc, SourceLoc keywordLoc,
47114711
Identifier name, SourceLoc nameLoc,
47124712
TypeRepr *defaultDefinition,
47134713
TrailingWhereClause *trailingWhere)
4714-
: AbstractTypeParamDecl(DeclKind::AssociatedType, dc, name, nameLoc),
4714+
: TypeDecl(DeclKind::AssociatedType, dc, name, nameLoc, { }),
47154715
KeywordLoc(keywordLoc), DefaultDefinition(defaultDefinition),
47164716
TrailingWhere(trailingWhere) {}
47174717

@@ -4720,7 +4720,7 @@ AssociatedTypeDecl::AssociatedTypeDecl(DeclContext *dc, SourceLoc keywordLoc,
47204720
TrailingWhereClause *trailingWhere,
47214721
LazyMemberLoader *definitionResolver,
47224722
uint64_t resolverData)
4723-
: AbstractTypeParamDecl(DeclKind::AssociatedType, dc, name, nameLoc),
4723+
: TypeDecl(DeclKind::AssociatedType, dc, name, nameLoc, { }),
47244724
KeywordLoc(keywordLoc), DefaultDefinition(nullptr),
47254725
TrailingWhere(trailingWhere), Resolver(definitionResolver),
47264726
ResolverContextData(resolverData) {

lib/SILGen/SILGen.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,8 @@ class LLVM_LIBRARY_VISIBILITY SILGenModule : public ASTVisitor<SILGenModule> {
272272
void visitPrecedenceGroupDecl(PrecedenceGroupDecl *d) {}
273273
void visitTypeAliasDecl(TypeAliasDecl *d) {}
274274
void visitOpaqueTypeDecl(OpaqueTypeDecl *d) {}
275-
void visitAbstractTypeParamDecl(AbstractTypeParamDecl *d) {}
275+
void visitGenericTypeParamDecl(GenericTypeParamDecl *d) {}
276+
void visitAssociatedTypeDecl(AssociatedTypeDecl *d) {}
276277
void visitConstructorDecl(ConstructorDecl *d) {}
277278
void visitDestructorDecl(DestructorDecl *d) {}
278279
void visitModuleDecl(ModuleDecl *d) { }

lib/SILGen/SILGenType.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,8 @@ class SILGenType : public TypeMemberVisitor<SILGenType> {
11211121
//===--------------------------------------------------------------------===//
11221122
void visitTypeAliasDecl(TypeAliasDecl *tad) {}
11231123
void visitOpaqueTypeDecl(OpaqueTypeDecl *otd) {}
1124-
void visitAbstractTypeParamDecl(AbstractTypeParamDecl *tpd) {}
1124+
void visitGenericTypeParamDecl(GenericTypeParamDecl *d) {}
1125+
void visitAssociatedTypeDecl(AssociatedTypeDecl *d) {}
11251126
void visitModuleDecl(ModuleDecl *md) {}
11261127
void visitMissingMemberDecl(MissingMemberDecl *) {}
11271128
void visitNominalTypeDecl(NominalTypeDecl *ntd) {
@@ -1276,7 +1277,8 @@ class SILGenExtension : public TypeMemberVisitor<SILGenExtension> {
12761277
//===--------------------------------------------------------------------===//
12771278
void visitTypeAliasDecl(TypeAliasDecl *tad) {}
12781279
void visitOpaqueTypeDecl(OpaqueTypeDecl *tad) {}
1279-
void visitAbstractTypeParamDecl(AbstractTypeParamDecl *tpd) {}
1280+
void visitGenericTypeParamDecl(GenericTypeParamDecl *d) {}
1281+
void visitAssociatedTypeDecl(AssociatedTypeDecl *d) {}
12801282
void visitModuleDecl(ModuleDecl *md) {}
12811283
void visitMissingMemberDecl(MissingMemberDecl *) {}
12821284
void visitNominalTypeDecl(NominalTypeDecl *ntd) {

0 commit comments

Comments
 (0)