@@ -1161,7 +1161,7 @@ void ASTMangler::appendType(Type type, GenericSignature sig,
1161
1161
1162
1162
appendAnyGenericType (decl);
1163
1163
bool isFirstArgList = true ;
1164
- appendBoundGenericArgs (type, sig, isFirstArgList);
1164
+ appendBoundGenericArgs (type, sig, isFirstArgList, forDecl );
1165
1165
appendRetroactiveConformances (type, sig);
1166
1166
appendOperator (" G" );
1167
1167
addTypeSubstitution (type, sig);
@@ -1290,7 +1290,7 @@ void ASTMangler::appendType(Type type, GenericSignature sig,
1290
1290
} else {
1291
1291
appendAnyGenericType (Decl);
1292
1292
bool isFirstArgList = true ;
1293
- appendBoundGenericArgs (type, sig, isFirstArgList);
1293
+ appendBoundGenericArgs (type, sig, isFirstArgList, forDecl );
1294
1294
appendRetroactiveConformances (type, sig);
1295
1295
appendOperator (" G" );
1296
1296
}
@@ -1302,7 +1302,8 @@ void ASTMangler::appendType(Type type, GenericSignature sig,
1302
1302
}
1303
1303
1304
1304
case TypeKind::SILFunction:
1305
- return appendImplFunctionType (cast<SILFunctionType>(tybase), sig);
1305
+ return appendImplFunctionType (cast<SILFunctionType>(tybase), sig,
1306
+ forDecl);
1306
1307
1307
1308
// type ::= archetype
1308
1309
case TypeKind::PrimaryArchetype:
@@ -1329,13 +1330,11 @@ void ASTMangler::appendType(Type type, GenericSignature sig,
1329
1330
bool isFirstArgList = true ;
1330
1331
appendBoundGenericArgs (opaqueDecl, sig,
1331
1332
opaqueType->getSubstitutions (),
1332
- isFirstArgList);
1333
+ isFirstArgList, forDecl );
1333
1334
appendRetroactiveConformances (opaqueType->getSubstitutions (), sig,
1334
1335
opaqueDecl->getParentModule ());
1335
1336
1336
- // TODO: If we support multiple opaque types in a return, put the
1337
- // ordinal for this archetype here.
1338
- appendOperator (" Qo" , Index (0 ));
1337
+ appendOperator (" Qo" , Index (opaqueType->getOrdinal ()));
1339
1338
1340
1339
addTypeSubstitution (type, sig);
1341
1340
return ;
@@ -1351,7 +1350,7 @@ void ASTMangler::appendType(Type type, GenericSignature sig,
1351
1350
if (tryMangleTypeSubstitution (nestedType, sig))
1352
1351
return ;
1353
1352
1354
- appendType (opaque, sig);
1353
+ appendType (opaque, sig, forDecl );
1355
1354
bool isAssocTypeAtDepth = false ;
1356
1355
appendAssocType (nestedType->getInterfaceType (),
1357
1356
sig, isAssocTypeAtDepth);
@@ -1360,7 +1359,7 @@ void ASTMangler::appendType(Type type, GenericSignature sig,
1360
1359
return ;
1361
1360
}
1362
1361
1363
- appendType (nestedType->getParent (), sig);
1362
+ appendType (nestedType->getParent (), sig, forDecl );
1364
1363
appendIdentifier (nestedType->getName ().str ());
1365
1364
appendOperator (" Qa" );
1366
1365
return ;
@@ -1516,20 +1515,22 @@ void ASTMangler::appendOpWithGenericParamIndex(StringRef Op,
1516
1515
}
1517
1516
1518
1517
void ASTMangler::appendFlatGenericArgs (SubstitutionMap subs,
1519
- GenericSignature sig) {
1518
+ GenericSignature sig,
1519
+ const ValueDecl *forDecl) {
1520
1520
appendOperator (" y" );
1521
1521
1522
1522
for (auto replacement : subs.getReplacementTypes ()) {
1523
1523
if (replacement->hasArchetype ())
1524
1524
replacement = replacement->mapTypeOutOfContext ();
1525
- appendType (replacement, sig);
1525
+ appendType (replacement, sig, forDecl );
1526
1526
}
1527
1527
}
1528
1528
1529
1529
unsigned ASTMangler::appendBoundGenericArgs (DeclContext *dc,
1530
1530
GenericSignature sig,
1531
1531
SubstitutionMap subs,
1532
- bool &isFirstArgList) {
1532
+ bool &isFirstArgList,
1533
+ const ValueDecl *forDecl) {
1533
1534
auto decl = dc->getInnermostDeclarationDeclContext ();
1534
1535
if (!decl) return 0 ;
1535
1536
@@ -1543,7 +1544,8 @@ unsigned ASTMangler::appendBoundGenericArgs(DeclContext *dc,
1543
1544
1544
1545
// Handle the generic arguments of the parent.
1545
1546
unsigned currentGenericParamIdx =
1546
- appendBoundGenericArgs (decl->getDeclContext (), sig, subs, isFirstArgList);
1547
+ appendBoundGenericArgs (decl->getDeclContext (), sig, subs, isFirstArgList,
1548
+ forDecl);
1547
1549
1548
1550
// If this is potentially a generic context, emit a generic argument list.
1549
1551
if (auto genericContext = decl->getAsGenericContext ()) {
@@ -1568,7 +1570,7 @@ unsigned ASTMangler::appendBoundGenericArgs(DeclContext *dc,
1568
1570
if (replacementType->hasArchetype ())
1569
1571
replacementType = replacementType->mapTypeOutOfContext ();
1570
1572
1571
- appendType (replacementType, sig);
1573
+ appendType (replacementType, sig, forDecl );
1572
1574
}
1573
1575
}
1574
1576
}
@@ -1577,29 +1579,33 @@ unsigned ASTMangler::appendBoundGenericArgs(DeclContext *dc,
1577
1579
}
1578
1580
1579
1581
void ASTMangler::appendBoundGenericArgs (Type type, GenericSignature sig,
1580
- bool &isFirstArgList) {
1582
+ bool &isFirstArgList,
1583
+ const ValueDecl *forDecl) {
1581
1584
TypeBase *typePtr = type.getPointer ();
1582
1585
ArrayRef<Type> genericArgs;
1583
1586
if (auto *typeAlias = dyn_cast<TypeAliasType>(typePtr)) {
1584
1587
appendBoundGenericArgs (typeAlias->getDecl (), sig,
1585
1588
typeAlias->getSubstitutionMap (),
1586
- isFirstArgList);
1589
+ isFirstArgList, forDecl );
1587
1590
return ;
1588
1591
}
1589
1592
1590
1593
if (auto *unboundType = dyn_cast<UnboundGenericType>(typePtr)) {
1591
1594
if (Type parent = unboundType->getParent ())
1592
- appendBoundGenericArgs (parent->getDesugaredType (), sig, isFirstArgList);
1595
+ appendBoundGenericArgs (parent->getDesugaredType (), sig, isFirstArgList,
1596
+ forDecl);
1593
1597
} else if (auto *nominalType = dyn_cast<NominalType>(typePtr)) {
1594
1598
if (Type parent = nominalType->getParent ())
1595
- appendBoundGenericArgs (parent->getDesugaredType (), sig, isFirstArgList);
1599
+ appendBoundGenericArgs (parent->getDesugaredType (), sig, isFirstArgList,
1600
+ forDecl);
1596
1601
} else {
1597
1602
auto boundType = cast<BoundGenericType>(typePtr);
1598
1603
genericArgs = boundType->getGenericArgs ();
1599
1604
if (Type parent = boundType->getParent ()) {
1600
1605
GenericTypeDecl *decl = boundType->getAnyGeneric ();
1601
1606
if (!getSpecialManglingContext (decl, UseObjCRuntimeNames))
1602
- appendBoundGenericArgs (parent->getDesugaredType (), sig, isFirstArgList);
1607
+ appendBoundGenericArgs (parent->getDesugaredType (), sig, isFirstArgList,
1608
+ forDecl);
1603
1609
}
1604
1610
}
1605
1611
if (isFirstArgList) {
@@ -1609,7 +1615,7 @@ void ASTMangler::appendBoundGenericArgs(Type type, GenericSignature sig,
1609
1615
appendOperator (" _" );
1610
1616
}
1611
1617
for (Type arg : genericArgs) {
1612
- appendType (arg, sig);
1618
+ appendType (arg, sig, forDecl );
1613
1619
}
1614
1620
}
1615
1621
@@ -1777,7 +1783,8 @@ getResultDifferentiability(SILResultDifferentiability diffKind) {
1777
1783
}
1778
1784
1779
1785
void ASTMangler::appendImplFunctionType (SILFunctionType *fn,
1780
- GenericSignature outerGenericSig) {
1786
+ GenericSignature outerGenericSig,
1787
+ const ValueDecl *forDecl) {
1781
1788
1782
1789
llvm::SmallVector<char , 32 > OpArgs;
1783
1790
@@ -1880,7 +1887,7 @@ void ASTMangler::appendImplFunctionType(SILFunctionType *fn,
1880
1887
OpArgs.push_back (getParamConvention (param.getConvention ()));
1881
1888
if (auto diffKind = getParamDifferentiability (param.getDifferentiability ()))
1882
1889
OpArgs.push_back (*diffKind);
1883
- appendType (param.getInterfaceType (), sig);
1890
+ appendType (param.getInterfaceType (), sig, forDecl );
1884
1891
}
1885
1892
1886
1893
// Mangle the results.
@@ -1889,30 +1896,30 @@ void ASTMangler::appendImplFunctionType(SILFunctionType *fn,
1889
1896
if (auto diffKind =
1890
1897
getResultDifferentiability (result.getDifferentiability ()))
1891
1898
OpArgs.push_back (*diffKind);
1892
- appendType (result.getInterfaceType (), sig);
1899
+ appendType (result.getInterfaceType (), sig, forDecl );
1893
1900
}
1894
1901
1895
1902
// Mangle the yields.
1896
1903
for (auto yield : fn->getYields ()) {
1897
1904
OpArgs.push_back (' Y' );
1898
1905
OpArgs.push_back (getParamConvention (yield.getConvention ()));
1899
- appendType (yield.getInterfaceType (), sig);
1906
+ appendType (yield.getInterfaceType (), sig, forDecl );
1900
1907
}
1901
1908
1902
1909
// Mangle the error result if present.
1903
1910
if (fn->hasErrorResult ()) {
1904
1911
auto error = fn->getErrorResult ();
1905
1912
OpArgs.push_back (' z' );
1906
1913
OpArgs.push_back (getResultConvention (error.getConvention ()));
1907
- appendType (error.getInterfaceType (), sig);
1914
+ appendType (error.getInterfaceType (), sig, forDecl );
1908
1915
}
1909
1916
1910
1917
if (auto invocationSig = fn->getInvocationGenericSignature ()) {
1911
1918
appendGenericSignature (invocationSig);
1912
1919
sig = outerGenericSig;
1913
1920
}
1914
1921
if (auto subs = fn->getInvocationSubstitutions ()) {
1915
- appendFlatGenericArgs (subs, sig);
1922
+ appendFlatGenericArgs (subs, sig, forDecl );
1916
1923
appendRetroactiveConformances (subs, sig, Mod);
1917
1924
}
1918
1925
if (auto subs = fn->getPatternSubstitutions ()) {
@@ -1921,7 +1928,7 @@ void ASTMangler::appendImplFunctionType(SILFunctionType *fn,
1921
1928
fn->getInvocationGenericSignature ()
1922
1929
? fn->getInvocationGenericSignature ()
1923
1930
: outerGenericSig;
1924
- appendFlatGenericArgs (subs, sig);
1931
+ appendFlatGenericArgs (subs, sig, forDecl );
1925
1932
appendRetroactiveConformances (subs, sig, Mod);
1926
1933
}
1927
1934
0 commit comments