@@ -538,7 +538,7 @@ static Type getTypeForDWARFMangling(Type t) {
538538 SubstFlags::AllowLoweredTypes);
539539}
540540
541- std::string ASTMangler::mangleTypeForDebugger (Type Ty, const DeclContext *DC ) {
541+ std::string ASTMangler::mangleTypeForDebugger (Type Ty, GenericSignature sig ) {
542542 PrettyStackTraceType prettyStackTrace (Ty->getASTContext (),
543543 " mangling type for debugger" , Ty);
544544
@@ -548,9 +548,7 @@ std::string ASTMangler::mangleTypeForDebugger(Type Ty, const DeclContext *DC) {
548548
549549 Ty = getTypeForDWARFMangling (Ty);
550550
551- if (DC)
552- bindGenericParameters (DC);
553-
551+ bindGenericParameters (sig);
554552 appendType (Ty);
555553 appendOperator (" D" );
556554 return finalize ();
@@ -676,7 +674,9 @@ std::string ASTMangler::mangleDeclAsUSR(const ValueDecl *Decl,
676674 beginManglingWithoutPrefix ();
677675 llvm::SaveAndRestore<bool > allowUnnamedRAII (AllowNamelessEntities, true );
678676 Buffer << USRPrefix;
679- bindGenericParameters (Decl->getDeclContext ());
677+
678+ auto Sig = Decl->getInnermostDeclContext ()->getGenericSignatureOfContext ();
679+ bindGenericParameters (Sig);
680680
681681 if (auto Ctor = dyn_cast<ConstructorDecl>(Decl)) {
682682 appendConstructorEntity (Ctor, /* isAllocating=*/ false );
@@ -1369,15 +1369,9 @@ void ASTMangler::appendOpWithGenericParamIndex(StringRef Op,
13691369
13701370
13711371// / Bind the generic parameters from the given signature.
1372- void ASTMangler::bindGenericParameters (CanGenericSignature sig) {
1372+ void ASTMangler::bindGenericParameters (GenericSignature sig) {
13731373 if (sig)
1374- CurGenericSignature = sig;
1375- }
1376-
1377- // / Bind the generic parameters from the given context and its parents.
1378- void ASTMangler::bindGenericParameters (const DeclContext *DC) {
1379- if (auto sig = DC->getGenericSignatureOfContext ())
1380- bindGenericParameters (sig.getCanonicalSignature ());
1374+ CurGenericSignature = sig.getCanonicalSignature ();
13811375}
13821376
13831377void ASTMangler::appendFlatGenericArgs (SubstitutionMap subs) {
@@ -2853,12 +2847,13 @@ void ASTMangler::appendAccessorEntity(StringRef accessorKindCode,
28532847 const AbstractStorageDecl *decl,
28542848 bool isStatic) {
28552849 appendContextOf (decl);
2856- bindGenericParameters (decl-> getDeclContext ());
2857- if (isa<VarDecl>(decl)) {
2850+ if ( auto *varDecl = dyn_cast<VarDecl>(decl)) {
2851+ bindGenericParameters (varDecl-> getDeclContext ()-> getGenericSignatureOfContext ());
28582852 appendDeclName (decl);
28592853 appendDeclType (decl);
28602854 appendOperator (" v" , accessorKindCode);
2861- } else if (isa<SubscriptDecl>(decl)) {
2855+ } else if (auto *subscriptDecl = dyn_cast<SubscriptDecl>(decl)) {
2856+ bindGenericParameters (subscriptDecl->getGenericSignature ());
28622857 appendDeclType (decl);
28632858
28642859 StringRef privateDiscriminator = getPrivateDiscriminatorIfNecessary (decl);
0 commit comments