1818#include " swift/AST/ASTContext.h"
1919#include " swift/AST/ASTVisitor.h"
2020#include " swift/AST/ExistentialLayout.h"
21- #include " swift/AST/GenericEnvironment .h"
21+ #include " swift/AST/GenericSignature .h"
2222#include " swift/AST/Initializer.h"
2323#include " swift/AST/Module.h"
2424#include " swift/AST/Ownership.h"
@@ -378,18 +378,15 @@ std::string ASTMangler::mangleReabstractionThunkHelper(
378378 return finalize ();
379379}
380380
381- std::string ASTMangler::mangleTypeForDebugger (Type Ty, const DeclContext *DC,
382- GenericEnvironment *GE) {
381+ std::string ASTMangler::mangleTypeForDebugger (Type Ty, const DeclContext *DC) {
383382 PrettyStackTraceType prettyStackTrace (Ty->getASTContext (),
384383 " mangling type for debugger" , Ty);
385384
386- GenericEnv = GE;
387385 DWARFMangling = true ;
388386 beginMangling ();
389387
390388 if (DC)
391389 bindGenericParameters (DC);
392- DeclCtx = DC;
393390
394391 if (auto *fnType = Ty->getAs <AnyFunctionType>()) {
395392 appendFunction (fnType, false );
@@ -682,20 +679,10 @@ static bool shouldMangleAsGeneric(Type type) {
682679 if (!type)
683680 return false ;
684681
685- TypeBase *typePtr = type.getPointer ();
686- if (auto typeAlias = dyn_cast<NameAliasType>(typePtr))
682+ if (auto typeAlias = dyn_cast<NameAliasType>(type.getPointer ()))
687683 return !typeAlias->getSubstitutionMap ().empty ();
688684
689- if (auto bound = dyn_cast<BoundGenericType>(typePtr))
690- return true ;
691-
692- if (auto nominal = dyn_cast<NominalType>(typePtr))
693- return shouldMangleAsGeneric (nominal->getParent ());
694-
695- if (auto unbound = dyn_cast<UnboundGenericType>(typePtr))
696- return shouldMangleAsGeneric (unbound->getParent ());
697-
698- return false ;
685+ return type->isSpecialized ();
699686}
700687
701688// / Mangle a type into the buffer.
@@ -1113,15 +1100,15 @@ void ASTMangler::appendBoundGenericArgs(Type type, bool &isFirstArgList) {
11131100
11141101 if (auto *unboundType = dyn_cast<UnboundGenericType>(typePtr)) {
11151102 if (Type parent = unboundType->getParent ())
1116- appendBoundGenericArgs (parent, isFirstArgList);
1103+ appendBoundGenericArgs (parent-> getDesugaredType () , isFirstArgList);
11171104 } else if (auto *nominalType = dyn_cast<NominalType>(typePtr)) {
11181105 if (Type parent = nominalType->getParent ())
1119- appendBoundGenericArgs (parent, isFirstArgList);
1106+ appendBoundGenericArgs (parent-> getDesugaredType () , isFirstArgList);
11201107 } else {
11211108 auto boundType = cast<BoundGenericType>(typePtr);
11221109 genericArgs = boundType->getGenericArgs ();
11231110 if (Type parent = boundType->getParent ())
1124- appendBoundGenericArgs (parent, isFirstArgList);
1111+ appendBoundGenericArgs (parent-> getDesugaredType () , isFirstArgList);
11251112 }
11261113 if (isFirstArgList) {
11271114 appendOperator (" y" );
@@ -2060,29 +2047,24 @@ void ASTMangler::appendAssociatedTypeName(DependentMemberType *dmt) {
20602047void ASTMangler::appendClosureEntity (
20612048 const SerializedAbstractClosureExpr *closure) {
20622049 appendClosureComponents (closure->getType (), closure->getDiscriminator (),
2063- closure->isImplicit (), closure->getParent (),
2064- closure->getLocalContext ());
2050+ closure->isImplicit (), closure->getParent ());
20652051}
20662052
20672053void ASTMangler::appendClosureEntity (const AbstractClosureExpr *closure) {
20682054 appendClosureComponents (closure->getType (), closure->getDiscriminator (),
2069- isa<AutoClosureExpr>(closure), closure->getParent (),
2070- closure->getLocalContext ());
2055+ isa<AutoClosureExpr>(closure), closure->getParent ());
20712056}
20722057
20732058void ASTMangler::appendClosureComponents (Type Ty, unsigned discriminator,
2074- bool isImplicit,
2075- const DeclContext *parentContext,
2076- const DeclContext *localContext) {
2077- if (!DeclCtx) DeclCtx = localContext;
2078-
2059+ bool isImplicit,
2060+ const DeclContext *parentContext) {
20792061 assert (discriminator != AbstractClosureExpr::InvalidDiscriminator
20802062 && " closure must be marked correctly with discriminator" );
20812063
20822064 appendContext (parentContext);
20832065
20842066 if (!Ty)
2085- Ty = ErrorType::get (localContext ->getASTContext ());
2067+ Ty = ErrorType::get (parentContext ->getASTContext ());
20862068
20872069 Ty = Ty->mapTypeOutOfContext ();
20882070 appendType (Ty->getCanonicalType ());
@@ -2226,7 +2208,6 @@ void ASTMangler::appendAccessorEntity(StringRef accessorKindCode,
22262208
22272209void ASTMangler::appendEntity (const ValueDecl *decl, StringRef EntityOp,
22282210 bool isStatic) {
2229- if (!DeclCtx) DeclCtx = decl->getInnermostDeclContext ();
22302211 appendContextOf (decl);
22312212 appendDeclName (decl);
22322213 appendDeclType (decl);
@@ -2236,7 +2217,6 @@ void ASTMangler::appendEntity(const ValueDecl *decl, StringRef EntityOp,
22362217}
22372218
22382219void ASTMangler::appendEntity (const ValueDecl *decl) {
2239- if (!DeclCtx) DeclCtx = decl->getInnermostDeclContext ();
22402220 assert (!isa<ConstructorDecl>(decl));
22412221 assert (!isa<DestructorDecl>(decl));
22422222
0 commit comments