@@ -2356,29 +2356,34 @@ CanType ASTMangler::getDeclTypeForMangling(
2356
2356
}
2357
2357
2358
2358
2359
- CanType type = decl->getInterfaceType ()
2360
- ->getReferenceStorageReferent ()
2361
- ->getCanonicalType ();
2362
- if (auto gft = dyn_cast<GenericFunctionType>(type)) {
2359
+ Type type = decl->getInterfaceType ()
2360
+ ->getReferenceStorageReferent ();
2361
+ if (type->hasArchetype ()) {
2362
+ assert (isa<ParamDecl>(decl) && " Only ParamDecl's still have archetypes" );
2363
+ type = type->mapTypeOutOfContext ();
2364
+ }
2365
+ CanType canTy = type->getCanonicalType ();
2366
+
2367
+ if (auto gft = dyn_cast<GenericFunctionType>(canTy)) {
2363
2368
genericSig = gft.getGenericSignature ();
2364
2369
CurGenericSignature = gft.getGenericSignature ();
2365
2370
2366
- type = CanFunctionType::get (gft.getParams (), gft.getResult (),
2367
- gft->getExtInfo ());
2371
+ canTy = CanFunctionType::get (gft.getParams (), gft.getResult (),
2372
+ gft->getExtInfo ());
2368
2373
}
2369
2374
2370
- if (!type ->hasError ()) {
2375
+ if (!canTy ->hasError ()) {
2371
2376
// Shed the 'self' type and generic requirements from method manglings.
2372
2377
if (isMethodDecl (decl)) {
2373
2378
// Drop the Self argument clause from the type.
2374
- type = cast<AnyFunctionType>(type ).getResult ();
2379
+ canTy = cast<AnyFunctionType>(canTy ).getResult ();
2375
2380
}
2376
2381
2377
2382
if (isMethodDecl (decl) || isa<SubscriptDecl>(decl))
2378
2383
parentGenericSig = decl->getDeclContext ()->getGenericSignatureOfContext ();
2379
2384
}
2380
2385
2381
- return type ;
2386
+ return canTy ;
2382
2387
}
2383
2388
2384
2389
void ASTMangler::appendDeclType (const ValueDecl *decl, bool isFunctionMangling) {
0 commit comments