@@ -32,7 +32,6 @@ namespace Mangle {
3232// / The mangler for AST declarations.
3333class ASTMangler : public Mangler {
3434protected:
35- CanGenericSignature CurGenericSignature;
3635 ModuleDecl *Mod = nullptr ;
3736
3837 // / Optimize out protocol names if a type only conforms to one protocol.
@@ -94,12 +93,12 @@ class ASTMangler : public Mangler {
9493 ASTMangler (bool DWARFMangling = false )
9594 : DWARFMangling(DWARFMangling) {}
9695
97- void addTypeSubstitution (Type type) {
98- type = dropProtocolsFromAssociatedTypes (type);
96+ void addTypeSubstitution (Type type, GenericSignature sig ) {
97+ type = dropProtocolsFromAssociatedTypes (type, sig );
9998 addSubstitution (type.getPointer ());
10099 }
101- bool tryMangleTypeSubstitution (Type type) {
102- type = dropProtocolsFromAssociatedTypes (type);
100+ bool tryMangleTypeSubstitution (Type type, GenericSignature sig ) {
101+ type = dropProtocolsFromAssociatedTypes (type, sig );
103102 return tryMangleSubstitution (type.getPointer ());
104103 }
105104
@@ -255,7 +254,7 @@ class ASTMangler : public Mangler {
255254 std::string mangleObjCRuntimeName (const NominalTypeDecl *Nominal);
256255
257256 std::string mangleTypeWithoutPrefix (Type type) {
258- appendType (type);
257+ appendType (type, nullptr );
259258 return finalize ();
260259 }
261260
@@ -293,18 +292,18 @@ class ASTMangler : public Mangler {
293292
294293 void appendSymbolKind (SymbolKind SKind);
295294
296- void appendType (Type type, const ValueDecl *forDecl = nullptr );
295+ void appendType (Type type, GenericSignature sig,
296+ const ValueDecl *forDecl = nullptr );
297297
298298 void appendDeclName (const ValueDecl *decl);
299299
300300 GenericTypeParamType *appendAssocType (DependentMemberType *DepTy,
301+ GenericSignature sig,
301302 bool &isAssocTypeAtDepth);
302303
303304 void appendOpWithGenericParamIndex (StringRef,
304305 const GenericTypeParamType *paramTy);
305306
306- void bindGenericParameters (GenericSignature sig);
307-
308307 // / Mangles a sugared type iff we are mangling for the debugger.
309308 template <class T > void appendSugaredType (Type type,
310309 const ValueDecl *forDecl) {
@@ -314,25 +313,29 @@ class ASTMangler : public Mangler {
314313 appendType (BlandTy, forDecl);
315314 }
316315
317- void appendBoundGenericArgs (Type type, bool &isFirstArgList);
316+ void appendBoundGenericArgs (Type type, GenericSignature sig,
317+ bool &isFirstArgList);
318318
319319 // / Append the bound generics arguments for the given declaration context
320320 // / based on a complete substitution map.
321321 // /
322322 // / \returns the number of generic parameters that were emitted
323323 // / thus far.
324324 unsigned appendBoundGenericArgs (DeclContext *dc,
325+ GenericSignature sig,
325326 SubstitutionMap subs,
326327 bool &isFirstArgList);
327328
328329 // / Append the bound generic arguments as a flat list, disregarding depth.
329- void appendFlatGenericArgs (SubstitutionMap subs);
330+ void appendFlatGenericArgs (SubstitutionMap subs,
331+ GenericSignature sig);
330332
331333 // / Append any retroactive conformances.
332- void appendRetroactiveConformances (Type type);
334+ void appendRetroactiveConformances (Type type, GenericSignature sig );
333335 void appendRetroactiveConformances (SubstitutionMap subMap,
336+ GenericSignature sig,
334337 ModuleDecl *fromModule);
335- void appendImplFunctionType (SILFunctionType *fn);
338+ void appendImplFunctionType (SILFunctionType *fn, GenericSignature sig );
336339
337340 void appendContextOf (const ValueDecl *decl);
338341
@@ -350,27 +353,33 @@ class ASTMangler : public Mangler {
350353 FunctionMangling,
351354 };
352355
353- void appendFunction (AnyFunctionType *fn,
356+ void appendFunction (AnyFunctionType *fn, GenericSignature sig,
354357 FunctionManglingKind functionMangling = NoFunctionMangling,
355358 const ValueDecl *forDecl = nullptr );
356- void appendFunctionType (AnyFunctionType *fn, bool isAutoClosure = false ,
359+ void appendFunctionType (AnyFunctionType *fn, GenericSignature sig,
360+ bool isAutoClosure = false ,
357361 const ValueDecl *forDecl = nullptr );
358362 void appendClangType (AnyFunctionType *fn);
359363 template <typename FnType>
360364 void appendClangType (FnType *fn, llvm::raw_svector_ostream &os);
361365
362366 void appendFunctionSignature (AnyFunctionType *fn,
367+ GenericSignature sig,
363368 const ValueDecl *forDecl,
364369 FunctionManglingKind functionMangling);
365370
366371 void appendFunctionInputType (ArrayRef<AnyFunctionType::Param> params,
372+ GenericSignature sig,
367373 const ValueDecl *forDecl = nullptr );
368374 void appendFunctionResultType (Type resultType,
375+ GenericSignature sig,
369376 const ValueDecl *forDecl = nullptr );
370377
371- void appendTypeList (Type listTy, const ValueDecl *forDecl = nullptr );
378+ void appendTypeList (Type listTy, GenericSignature sig,
379+ const ValueDecl *forDecl = nullptr );
372380 void appendTypeListElement (Identifier name, Type elementType,
373381 ParameterTypeFlags flags,
382+ GenericSignature sig,
374383 const ValueDecl *forDecl = nullptr );
375384
376385 // / Append a generic signature to the mangling.
@@ -385,16 +394,21 @@ class ASTMangler : public Mangler {
385394 bool appendGenericSignature (GenericSignature sig,
386395 GenericSignature contextSig = nullptr );
387396
388- void appendRequirement (const Requirement &reqt);
397+ void appendRequirement (const Requirement &reqt,
398+ GenericSignature sig);
389399
390- void appendGenericSignatureParts (ArrayRef<CanTypeWrapper<GenericTypeParamType>> params,
400+ void appendGenericSignatureParts (GenericSignature sig,
401+ ArrayRef<CanTypeWrapper<GenericTypeParamType>> params,
391402 unsigned initialParamDepth,
392403 ArrayRef<Requirement> requirements);
393404
394- DependentMemberType *dropProtocolFromAssociatedType (DependentMemberType *dmt);
395- Type dropProtocolsFromAssociatedTypes (Type type);
405+ DependentMemberType *dropProtocolFromAssociatedType (DependentMemberType *dmt,
406+ GenericSignature sig);
407+ Type dropProtocolsFromAssociatedTypes (Type type,
408+ GenericSignature sig);
396409
397- void appendAssociatedTypeName (DependentMemberType *dmt);
410+ void appendAssociatedTypeName (DependentMemberType *dmt,
411+ GenericSignature sig);
398412
399413 void appendClosureEntity (const SerializedAbstractClosureExpr *closure);
400414
@@ -437,12 +451,14 @@ class ASTMangler : public Mangler {
437451
438452 void appendProtocolConformance (const ProtocolConformance *conformance);
439453 void appendProtocolConformanceRef (const RootProtocolConformance *conformance);
440- void appendAnyProtocolConformance (CanGenericSignature genericSig,
454+ void appendAnyProtocolConformance (GenericSignature genericSig,
441455 CanType conformingType,
442456 ProtocolConformanceRef conformance);
443457 void appendConcreteProtocolConformance (
444- const ProtocolConformance *conformance);
445- void appendDependentProtocolConformance (const ConformanceAccessPath &path);
458+ const ProtocolConformance *conformance,
459+ GenericSignature sig);
460+ void appendDependentProtocolConformance (const ConformanceAccessPath &path,
461+ GenericSignature sig);
446462 void appendOpParamForLayoutConstraint (LayoutConstraint Layout);
447463
448464 void appendSymbolicReference (SymbolicReferent referent);
0 commit comments