From 472c863710cc6cad4a836947f6523a40209c467e Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 1 Nov 2022 14:34:04 -0400 Subject: [PATCH 1/7] ClangImporter: Clean up to use ArchetypeType::getExistentialType() --- lib/ClangImporter/ImportType.cpp | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/lib/ClangImporter/ImportType.cpp b/lib/ClangImporter/ImportType.cpp index 1aec58412eb64..72013c9d2487a 100644 --- a/lib/ClangImporter/ImportType.cpp +++ b/lib/ClangImporter/ImportType.cpp @@ -24,6 +24,7 @@ #include "swift/AST/DiagnosticEngine.h" #include "swift/AST/DiagnosticsClangImporter.h" #include "swift/AST/ExistentialLayout.h" +#include "swift/AST/GenericEnvironment.h" #include "swift/AST/GenericParamList.h" #include "swift/AST/GenericSignature.h" #include "swift/AST/Module.h" @@ -1071,29 +1072,13 @@ namespace { importedTypeArgs.push_back(importedTypeArg); } } else { - for (auto typeParam : imported->getGenericParams()->getParams()) { - if (typeParam->getSuperclass() && - typeParam->getConformingProtocols().empty()) { - importedTypeArgs.push_back(typeParam->getSuperclass()); - continue; - } - - SmallVector memberTypes; - - if (auto superclassType = typeParam->getSuperclass()) - memberTypes.push_back(superclassType); + auto *genericEnv = imported->getGenericEnvironment(); - for (auto protocolDecl : typeParam->getConformingProtocols()) - memberTypes.push_back(protocolDecl->getDeclaredInterfaceType()); - - bool hasExplicitAnyObject = false; - if (memberTypes.empty()) - hasExplicitAnyObject = true; - - Type importedTypeArg = ExistentialType::get( - ProtocolCompositionType::get( - Impl.SwiftContext, memberTypes, - hasExplicitAnyObject)); + for (auto typeParam : imported->getGenericParams()->getParams()) { + Type importedTypeArg = genericEnv->mapTypeIntoContext( + typeParam->getDeclaredInterfaceType()) + ->castTo() + ->getExistentialType(); importedTypeArgs.push_back(importedTypeArg); } } From 7848b4f4e09eb21052a606088a85bad488d83a08 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 1 Nov 2022 14:41:52 -0400 Subject: [PATCH 2/7] Sema: Remove usages of AbstractTypeParamDecl::getSuperclass()/getConformedProtocols() --- lib/Sema/CSRanking.cpp | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/lib/Sema/CSRanking.cpp b/lib/Sema/CSRanking.cpp index 0af0e1f00ecb7..cc4cf3732e1a5 100644 --- a/lib/Sema/CSRanking.cpp +++ b/lib/Sema/CSRanking.cpp @@ -238,33 +238,38 @@ static bool isDeclMoreConstrainedThan(ValueDecl *decl1, ValueDecl *decl2) { if (decl1->getKind() != decl2->getKind() || isa(decl1)) return false; - GenericParamList *gp1 = nullptr, *gp2 = nullptr; + bool bothGeneric = false; + GenericSignature sig1, sig2; auto func1 = dyn_cast(decl1); auto func2 = dyn_cast(decl2); if (func1 && func2) { - gp1 = func1->getGenericParams(); - gp2 = func2->getGenericParams(); + bothGeneric = func1->isGeneric() && func2->isGeneric(); + + sig1 = func1->getGenericSignature(); + sig2 = func2->getGenericSignature(); } auto subscript1 = dyn_cast(decl1); auto subscript2 = dyn_cast(decl2); if (subscript1 && subscript2) { - gp1 = subscript1->getGenericParams(); - gp2 = subscript2->getGenericParams(); + bothGeneric = subscript1->isGeneric() && subscript2->isGeneric(); + + sig1 = subscript1->getGenericSignature(); + sig2 = subscript2->getGenericSignature(); } - if (gp1 && gp2) { - auto params1 = gp1->getParams(); - auto params2 = gp2->getParams(); + if (bothGeneric) { + auto params1 = sig1.getInnermostGenericParams(); + auto params2 = sig2.getInnermostGenericParams(); if (params1.size() == params2.size()) { for (size_t i = 0; i < params1.size(); i++) { auto p1 = params1[i]; auto p2 = params2[i]; - int np1 = static_cast(p1->getConformingProtocols().size()); - int np2 = static_cast(p2->getConformingProtocols().size()); + int np1 = static_cast(sig1->getRequiredProtocols(p1).size()); + int np2 = static_cast(sig2->getRequiredProtocols(p2).size()); int aDelta = np1 - np2; if (aDelta) From b94cd94e3390650d3940c6cbb3ba07c8acfc8c9b Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 1 Nov 2022 15:06:41 -0400 Subject: [PATCH 3/7] ASTPrinter: Remove usages of AbstractTypeParamDecl::getConformedProtocols() --- lib/AST/ASTPrinter.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/lib/AST/ASTPrinter.cpp b/lib/AST/ASTPrinter.cpp index 8a81f743adc96..58778bfe5fa1f 100644 --- a/lib/AST/ASTPrinter.cpp +++ b/lib/AST/ASTPrinter.cpp @@ -6559,16 +6559,13 @@ class TypePrinter : public TypeVisitor { // Print based on the type. Printer << "some "; - if (!decl->getConformingProtocols().empty()) { - llvm::interleave(decl->getConformingProtocols(), Printer, [&](ProtocolDecl *proto){ - if (auto printType = proto->getDeclaredType()) - printType->print(Printer, Options); - else - Printer << proto->getNameStr(); - }, " & "); - } else { - Printer << "Any"; - } + auto archetypeType = decl->getDeclContext()->mapTypeIntoContext( + decl->getDeclaredInterfaceType())->castTo(); + auto constraintType = archetypeType->getExistentialType(); + if (auto *existentialType = constraintType->getAs()) + constraintType = existentialType->getConstraintType(); + + constraintType->print(Printer, Options); return; } From 8113d1f0c79c616ec11d131322dc6a416c2c7850 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 1 Nov 2022 18:27:52 -0400 Subject: [PATCH 4/7] IDE: Remove bogus associated type superclass field from ModuleAPIDiff --- tools/swift-ide-test/ModuleAPIDiff.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/tools/swift-ide-test/ModuleAPIDiff.cpp b/tools/swift-ide-test/ModuleAPIDiff.cpp index 4b730d2d9f774..5854d1d6831ec 100644 --- a/tools/swift-ide-test/ModuleAPIDiff.cpp +++ b/tools/swift-ide-test/ModuleAPIDiff.cpp @@ -394,7 +394,6 @@ struct TypealiasDecl { struct AssociatedTypeDecl { Identifier Name; - Optional Superclass; Optional DefaultDefinition; DeclAttributes Attributes; }; @@ -603,7 +602,6 @@ template <> struct MappingTraits<::swift::sma::TypealiasDecl> { template <> struct MappingTraits<::swift::sma::AssociatedTypeDecl> { static void mapping(IO &io, ::swift::sma::AssociatedTypeDecl &ATD) { io.mapRequired("Name", ATD.Name); - io.mapOptional("Superclass", ATD.Superclass); io.mapOptional("DefaultDefinition", ATD.DefaultDefinition); io.mapOptional("Attributes", ATD.Attributes, ::swift::sma::DeclAttributes()); @@ -844,7 +842,6 @@ class SMAModelGenerator : public DeclVisitor { void visitAssociatedTypeDecl(AssociatedTypeDecl *ATD) { auto ResultATD = std::make_shared(); ResultATD->Name = convertToIdentifier(ATD->getName()); - ResultATD->Superclass = convertToOptionalTypeName(ATD->getSuperclass()); ResultATD->DefaultDefinition = convertToOptionalTypeName(ATD->getDefaultDefinitionType()); // FIXME From ad06d27e88ec00bfa5c9257eb770cd11a618b304 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 1 Nov 2022 15:07:02 -0400 Subject: [PATCH 5/7] AST: Remove AbstractTypeParamDecl::getSuperclass()/getConformingProtocols() --- include/swift/AST/Decl.h | 7 ------- lib/AST/Decl.cpp | 25 ------------------------- 2 files changed, 32 deletions(-) diff --git a/include/swift/AST/Decl.h b/include/swift/AST/Decl.h index 423a1fb49f708..4abf3b83a2f63 100644 --- a/include/swift/AST/Decl.h +++ b/include/swift/AST/Decl.h @@ -3192,13 +3192,6 @@ class AbstractTypeParamDecl : public TypeDecl { : TypeDecl(kind, dc, name, NameLoc, { }) { } public: - /// Return the superclass of the generic parameter. - Type getSuperclass() const; - - /// Retrieve the set of protocols to which this abstract type - /// parameter conforms. - ArrayRef getConformingProtocols() const; - static bool classof(const Decl *D) { return D->getKind() >= DeclKind::First_AbstractTypeParamDecl && D->getKind() <= DeclKind::Last_AbstractTypeParamDecl; diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 49526c20b9cf2..429fd79360263 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -4623,31 +4623,6 @@ Type TypeAliasDecl::getStructuralType() const { return ErrorType::get(ctx); } -Type AbstractTypeParamDecl::getSuperclass() const { - auto *genericEnv = getDeclContext()->getGenericEnvironmentOfContext(); - assert(genericEnv != nullptr && "Too much circularity"); - - auto contextTy = genericEnv->mapTypeIntoContext(getDeclaredInterfaceType()); - if (auto *archetype = contextTy->getAs()) - return archetype->getSuperclass(); - - // FIXME: Assert that this is never queried. - return nullptr; -} - -ArrayRef -AbstractTypeParamDecl::getConformingProtocols() const { - auto *genericEnv = getDeclContext()->getGenericEnvironmentOfContext(); - assert(genericEnv != nullptr && "Too much circularity"); - - auto contextTy = genericEnv->mapTypeIntoContext(getDeclaredInterfaceType()); - if (auto *archetype = contextTy->getAs()) - return archetype->getConformsTo(); - - // FIXME: Assert that this is never queried. - return { }; -} - GenericTypeParamDecl::GenericTypeParamDecl( DeclContext *dc, Identifier name, SourceLoc nameLoc, SourceLoc ellipsisLoc, unsigned depth, unsigned index, bool isParameterPack, bool isOpaqueType, From 0e4ccb21ed8614cb781bb1ce3b499e7ee926cb35 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 1 Nov 2022 15:20:45 -0400 Subject: [PATCH 6/7] AST: Remove various references to AbstractTypeParamDecl --- include/swift/AST/Decl.h | 2 +- lib/AST/ASTWalker.cpp | 26 ++++++++++++++--------- lib/AST/Decl.cpp | 6 +++--- lib/AST/NameLookup.cpp | 3 ++- lib/IDE/CodeCompletionResultBuilder.cpp | 2 +- lib/PrintAsClang/ModuleContentsWriter.cpp | 6 ++++-- lib/Sema/TypeCheckDeclPrimary.cpp | 7 +++--- 7 files changed, 31 insertions(+), 21 deletions(-) diff --git a/include/swift/AST/Decl.h b/include/swift/AST/Decl.h index 4abf3b83a2f63..97ea79c54c565 100644 --- a/include/swift/AST/Decl.h +++ b/include/swift/AST/Decl.h @@ -3503,7 +3503,7 @@ class AssociatedTypeDecl : public AbstractTypeParamDecl { /// Retrieve the (first) overridden associated type declaration, if any. AssociatedTypeDecl *getOverriddenDecl() const { return cast_or_null( - AbstractTypeParamDecl::getOverriddenDecl()); + TypeDecl::getOverriddenDecl()); } /// Retrieve the set of associated types overridden by this associated diff --git a/lib/AST/ASTWalker.cpp b/lib/AST/ASTWalker.cpp index 4bf6c0bd5e070..6af46331f0e5c 100644 --- a/lib/AST/ASTWalker.cpp +++ b/lib/AST/ASTWalker.cpp @@ -275,23 +275,29 @@ class Traversal : public ASTVisitorgetInherited()) { + bool visitGenericTypeParamDecl(GenericTypeParamDecl *GTPD) { + for (const auto &Inherit: GTPD->getInherited()) { if (auto *const TyR = Inherit.getTypeRepr()) if (doIt(TyR)) return true; } + return false; + } - if (const auto ATD = dyn_cast(TPD)) { - if (const auto DefaultTy = ATD->getDefaultDefinitionTypeRepr()) - if (doIt(DefaultTy)) + bool visitAssociatedTypeDecl(AssociatedTypeDecl *ATD) { + for (const auto &Inherit: ATD->getInherited()) { + if (auto *const TyR = Inherit.getTypeRepr()) + if (doIt(TyR)) return true; + } + if (const auto DefaultTy = ATD->getDefaultDefinitionTypeRepr()) + if (doIt(DefaultTy)) + return true; - if (auto *WhereClause = ATD->getTrailingWhereClause()) { - for (auto &Req: WhereClause->getRequirements()) { - if (doIt(Req)) - return true; - } + if (auto *WhereClause = ATD->getTrailingWhereClause()) { + for (auto &Req: WhereClause->getRequirements()) { + if (doIt(Req)) + return true; } } return false; diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 429fd79360263..1a59b79251b0c 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -547,7 +547,7 @@ bool Decl::canHaveComment() const { return !this->hasClangNode() && (isa(this) || isa(this)) && !isa(this) && - (!isa(this) || isa(this)); + !isa(this); } ModuleDecl *Decl::getModuleContext() const { @@ -4756,7 +4756,7 @@ AssociatedTypeDecl::getOverriddenDecls() const { if (auto cached = request.getCachedResult()) overridden = std::move(*cached); else - overridden = AbstractTypeParamDecl::getOverriddenDecls(); + overridden = TypeDecl::getOverriddenDecls(); llvm::TinyPtrVector assocTypes; for (auto decl : overridden) { @@ -4784,7 +4784,7 @@ static AssociatedTypeDecl *getAssociatedTypeAnchor( auto anchor = getAssociatedTypeAnchor(assocType, searched); if (!anchor) continue; - if (!bestAnchor || AbstractTypeParamDecl::compare(anchor, bestAnchor) < 0) + if (!bestAnchor || TypeDecl::compare(anchor, bestAnchor) < 0) bestAnchor = anchor; } diff --git a/lib/AST/NameLookup.cpp b/lib/AST/NameLookup.cpp index d3d9510263270..2b41e7d8bdb87 100644 --- a/lib/AST/NameLookup.cpp +++ b/lib/AST/NameLookup.cpp @@ -2300,7 +2300,8 @@ resolveTypeDeclsToNominal(Evaluator &evaluator, } // Make sure we didn't miss some interesting kind of type declaration. - assert(isa(typeDecl)); + assert(isa(typeDecl) || + isa(typeDecl)); } return nominalDecls; diff --git a/lib/IDE/CodeCompletionResultBuilder.cpp b/lib/IDE/CodeCompletionResultBuilder.cpp index 96432bdfd74d1..202f29f655c0d 100644 --- a/lib/IDE/CodeCompletionResultBuilder.cpp +++ b/lib/IDE/CodeCompletionResultBuilder.cpp @@ -27,7 +27,7 @@ using namespace swift::ide; static bool shouldCopyAssociatedUSRForDecl(const ValueDecl *VD) { // Avoid trying to generate a USR for some declaration types. - if (isa(VD) && !isa(VD)) + if (isa(VD)) return false; if (isa(VD)) return false; diff --git a/lib/PrintAsClang/ModuleContentsWriter.cpp b/lib/PrintAsClang/ModuleContentsWriter.cpp index b508127979516..c145e2223259f 100644 --- a/lib/PrintAsClang/ModuleContentsWriter.cpp +++ b/lib/PrintAsClang/ModuleContentsWriter.cpp @@ -314,8 +314,10 @@ class ModuleWriter { return; } else if (auto ED = dyn_cast(TD)) { forwardDeclare(ED); - } else if (isa(TD)) { - llvm_unreachable("should not see type params here"); + } else if (isa(TD)) { + llvm_unreachable("should not see generic parameters here"); + } else if (isa(TD)) { + llvm_unreachable("should not see associated types here"); } else if (isa(TD) && TD->getModuleContext()->isStdlibModule()) { // stdlib has some @_cdecl functions with structs. diff --git a/lib/Sema/TypeCheckDeclPrimary.cpp b/lib/Sema/TypeCheckDeclPrimary.cpp index 33e64e8ace3c7..e869b739fb7e6 100644 --- a/lib/Sema/TypeCheckDeclPrimary.cpp +++ b/lib/Sema/TypeCheckDeclPrimary.cpp @@ -180,7 +180,8 @@ static void checkInheritanceClause( // For generic parameters and associated types, the GSB checks constraints; // however, we still want to fire off the requests to produce diagnostics // in some circular validation cases. - if (isa(decl)) + if (isa(decl) || + isa(decl)) continue; // Check whether we inherited from 'AnyObject' twice. @@ -192,7 +193,7 @@ static void checkInheritanceClause( // for Swift >= 5. auto sourceRange = inherited.getSourceRange(); bool isWrittenAsClass = - (isa(decl) || isa(decl)) && + isa(decl) && Lexer::getTokenAtLocation(ctx.SourceMgr, sourceRange.Start) .is(tok::kw_class); if (ctx.LangOpts.isSwiftVersionAtLeast(5) && isWrittenAsClass) { @@ -210,7 +211,7 @@ static void checkInheritanceClause( auto knownRange = inheritedAnyObject->second; SourceRange removeRange = getRemovalRange(knownIndex); if (!ctx.LangOpts.isSwiftVersionAtLeast(5) && - (isa(decl) || isa(decl)) && + isa(decl) && Lexer::getTokenAtLocation(ctx.SourceMgr, knownRange.Start) .is(tok::kw_class)) { SourceLoc classLoc = knownRange.Start; From 36b3f0ee12de9ca0755f5737b57bb5b47f16be99 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 1 Nov 2022 19:08:07 -0400 Subject: [PATCH 7/7] AST: Remove AbstractTypeParamDecl --- include/swift/AST/Decl.h | 23 +++-------------------- include/swift/AST/DeclNodes.def | 6 ++---- lib/AST/ASTDumper.cpp | 9 ++------- lib/AST/Decl.cpp | 6 +++--- lib/SILGen/SILGen.h | 3 ++- lib/SILGen/SILGenType.cpp | 6 ++++-- 6 files changed, 16 insertions(+), 37 deletions(-) diff --git a/include/swift/AST/Decl.h b/include/swift/AST/Decl.h index 97ea79c54c565..19df1fd04f1bb 100644 --- a/include/swift/AST/Decl.h +++ b/include/swift/AST/Decl.h @@ -499,9 +499,8 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated { ); SWIFT_INLINE_BITFIELD_EMPTY(TypeDecl, ValueDecl); - SWIFT_INLINE_BITFIELD_EMPTY(AbstractTypeParamDecl, TypeDecl); - SWIFT_INLINE_BITFIELD_FULL(GenericTypeParamDecl, AbstractTypeParamDecl, 16+16+1+1, + SWIFT_INLINE_BITFIELD_FULL(GenericTypeParamDecl, TypeDecl, 16+16+1+1, : NumPadBits, Depth : 16, @@ -3182,22 +3181,6 @@ class TypeAliasDecl : public GenericTypeDecl { } }; -/// Abstract class describing generic type parameters and associated types, -/// whose common purpose is to anchor the abstract type parameter and specify -/// requirements for any corresponding type argument. -class AbstractTypeParamDecl : public TypeDecl { -protected: - AbstractTypeParamDecl(DeclKind kind, DeclContext *dc, Identifier name, - SourceLoc NameLoc) - : TypeDecl(kind, dc, name, NameLoc, { }) { } - -public: - static bool classof(const Decl *D) { - return D->getKind() >= DeclKind::First_AbstractTypeParamDecl && - D->getKind() <= DeclKind::Last_AbstractTypeParamDecl; - } -}; - /// A declaration of a generic type parameter. /// /// A generic type parameter introduces a new, named type parameter along @@ -3212,7 +3195,7 @@ class AbstractTypeParamDecl : public TypeDecl { /// func min(x : T, y : T) -> T { ... } /// \endcode class GenericTypeParamDecl final - : public AbstractTypeParamDecl, + : public TypeDecl, private llvm::TrailingObjects { friend TrailingObjects; @@ -3439,7 +3422,7 @@ class GenericTypeParamDecl final /// func getNext() -> Element? /// } /// \endcode -class AssociatedTypeDecl : public AbstractTypeParamDecl { +class AssociatedTypeDecl : public TypeDecl { /// The location of the initial keyword. SourceLoc KeywordLoc; diff --git a/include/swift/AST/DeclNodes.def b/include/swift/AST/DeclNodes.def index 6aeb86b202130..fea649cc0db56 100644 --- a/include/swift/AST/DeclNodes.def +++ b/include/swift/AST/DeclNodes.def @@ -156,10 +156,8 @@ ABSTRACT_DECL(Value, Decl) GENERIC_VALUE_DECL(OpaqueType, GenericTypeDecl) GENERIC_VALUE_DECL(TypeAlias, GenericTypeDecl) DECL_RANGE(GenericType, Enum, TypeAlias) - ABSTRACT_DECL(AbstractTypeParam, TypeDecl) - VALUE_DECL(GenericTypeParam, AbstractTypeParamDecl) - VALUE_DECL(AssociatedType, AbstractTypeParamDecl) - DECL_RANGE(AbstractTypeParam, GenericTypeParam, AssociatedType) + VALUE_DECL(GenericTypeParam, TypeDecl) + VALUE_DECL(AssociatedType, TypeDecl) CONTEXT_VALUE_DECL(Module, TypeDecl) DECL_RANGE(Type, Enum, Module) ABSTRACT_DECL(AbstractStorage, ValueDecl) diff --git a/lib/AST/ASTDumper.cpp b/lib/AST/ASTDumper.cpp index 2226e1c4e430e..edced0f28ab00 100644 --- a/lib/AST/ASTDumper.cpp +++ b/lib/AST/ASTDumper.cpp @@ -648,19 +648,14 @@ namespace { PrintWithColorRAII(OS, ParenthesisColor) << ')'; } - void printAbstractTypeParamCommon(AbstractTypeParamDecl *decl, - const char *name) { - printCommon(decl, name); - } - void visitGenericTypeParamDecl(GenericTypeParamDecl *decl) { - printAbstractTypeParamCommon(decl, "generic_type_param"); + printCommon(decl, "generic_type_param"); OS << " depth=" << decl->getDepth() << " index=" << decl->getIndex(); PrintWithColorRAII(OS, ParenthesisColor) << ')'; } void visitAssociatedTypeDecl(AssociatedTypeDecl *decl) { - printAbstractTypeParamCommon(decl, "associated_type_decl"); + printCommon(decl, "associated_type_decl"); if (auto defaultDef = decl->getDefaultDefinitionType()) { OS << " default="; defaultDef.print(OS); diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 1a59b79251b0c..dacbdd4770c99 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -4627,7 +4627,7 @@ GenericTypeParamDecl::GenericTypeParamDecl( DeclContext *dc, Identifier name, SourceLoc nameLoc, SourceLoc ellipsisLoc, unsigned depth, unsigned index, bool isParameterPack, bool isOpaqueType, TypeRepr *opaqueTypeRepr) - : AbstractTypeParamDecl(DeclKind::GenericTypeParam, dc, name, nameLoc) { + : TypeDecl(DeclKind::GenericTypeParam, dc, name, nameLoc, { }) { assert(!(ellipsisLoc && !isParameterPack) && "Ellipsis always means type parameter pack"); @@ -4711,7 +4711,7 @@ AssociatedTypeDecl::AssociatedTypeDecl(DeclContext *dc, SourceLoc keywordLoc, Identifier name, SourceLoc nameLoc, TypeRepr *defaultDefinition, TrailingWhereClause *trailingWhere) - : AbstractTypeParamDecl(DeclKind::AssociatedType, dc, name, nameLoc), + : TypeDecl(DeclKind::AssociatedType, dc, name, nameLoc, { }), KeywordLoc(keywordLoc), DefaultDefinition(defaultDefinition), TrailingWhere(trailingWhere) {} @@ -4720,7 +4720,7 @@ AssociatedTypeDecl::AssociatedTypeDecl(DeclContext *dc, SourceLoc keywordLoc, TrailingWhereClause *trailingWhere, LazyMemberLoader *definitionResolver, uint64_t resolverData) - : AbstractTypeParamDecl(DeclKind::AssociatedType, dc, name, nameLoc), + : TypeDecl(DeclKind::AssociatedType, dc, name, nameLoc, { }), KeywordLoc(keywordLoc), DefaultDefinition(nullptr), TrailingWhere(trailingWhere), Resolver(definitionResolver), ResolverContextData(resolverData) { diff --git a/lib/SILGen/SILGen.h b/lib/SILGen/SILGen.h index 3b7b14cf369e5..1240e53b98003 100644 --- a/lib/SILGen/SILGen.h +++ b/lib/SILGen/SILGen.h @@ -272,7 +272,8 @@ class LLVM_LIBRARY_VISIBILITY SILGenModule : public ASTVisitor { void visitPrecedenceGroupDecl(PrecedenceGroupDecl *d) {} void visitTypeAliasDecl(TypeAliasDecl *d) {} void visitOpaqueTypeDecl(OpaqueTypeDecl *d) {} - void visitAbstractTypeParamDecl(AbstractTypeParamDecl *d) {} + void visitGenericTypeParamDecl(GenericTypeParamDecl *d) {} + void visitAssociatedTypeDecl(AssociatedTypeDecl *d) {} void visitConstructorDecl(ConstructorDecl *d) {} void visitDestructorDecl(DestructorDecl *d) {} void visitModuleDecl(ModuleDecl *d) { } diff --git a/lib/SILGen/SILGenType.cpp b/lib/SILGen/SILGenType.cpp index ea27c241553c2..79bc7522a85b2 100644 --- a/lib/SILGen/SILGenType.cpp +++ b/lib/SILGen/SILGenType.cpp @@ -1121,7 +1121,8 @@ class SILGenType : public TypeMemberVisitor { //===--------------------------------------------------------------------===// void visitTypeAliasDecl(TypeAliasDecl *tad) {} void visitOpaqueTypeDecl(OpaqueTypeDecl *otd) {} - void visitAbstractTypeParamDecl(AbstractTypeParamDecl *tpd) {} + void visitGenericTypeParamDecl(GenericTypeParamDecl *d) {} + void visitAssociatedTypeDecl(AssociatedTypeDecl *d) {} void visitModuleDecl(ModuleDecl *md) {} void visitMissingMemberDecl(MissingMemberDecl *) {} void visitNominalTypeDecl(NominalTypeDecl *ntd) { @@ -1276,7 +1277,8 @@ class SILGenExtension : public TypeMemberVisitor { //===--------------------------------------------------------------------===// void visitTypeAliasDecl(TypeAliasDecl *tad) {} void visitOpaqueTypeDecl(OpaqueTypeDecl *tad) {} - void visitAbstractTypeParamDecl(AbstractTypeParamDecl *tpd) {} + void visitGenericTypeParamDecl(GenericTypeParamDecl *d) {} + void visitAssociatedTypeDecl(AssociatedTypeDecl *d) {} void visitModuleDecl(ModuleDecl *md) {} void visitMissingMemberDecl(MissingMemberDecl *) {} void visitNominalTypeDecl(NominalTypeDecl *ntd) {