@@ -1290,7 +1290,7 @@ buildDescriptorPath(const ContextDescriptor *context) const {
1290
1290
if (!context)
1291
1291
return 0 ;
1292
1292
1293
- // Add the parent's contributino to the descriptor path.
1293
+ // Add the parent's contribution to the descriptor path.
1294
1294
unsigned numKeyGenericParamsInParent =
1295
1295
buildDescriptorPath (context->Parent .get ());
1296
1296
@@ -1301,15 +1301,18 @@ buildDescriptorPath(const ContextDescriptor *context) const {
1301
1301
// Count the number of key generic params at this level.
1302
1302
unsigned numKeyGenericParamsHere = 0 ;
1303
1303
bool hasNonKeyGenericParams = false ;
1304
- for (const auto &genericParam : getLocalGenericParams (context)) {
1304
+ auto localGenericParams = getLocalGenericParams (context);
1305
+ for (const auto &genericParam : localGenericParams) {
1305
1306
if (genericParam.hasKeyArgument ())
1306
1307
++numKeyGenericParamsHere;
1307
1308
else
1308
1309
hasNonKeyGenericParams = true ;
1309
1310
}
1310
1311
1311
1312
// Form the path element.
1312
- descriptorPath.push_back (PathElement{context, numKeyGenericParamsInParent,
1313
+ descriptorPath.push_back (PathElement{localGenericParams,
1314
+ context->getNumGenericParams (),
1315
+ numKeyGenericParamsInParent,
1313
1316
numKeyGenericParamsHere,
1314
1317
hasNonKeyGenericParams});
1315
1318
return numKeyGenericParamsInParent + numKeyGenericParamsHere;
@@ -1335,18 +1338,17 @@ SubstGenericParametersFromMetadata::operator()(
1335
1338
1336
1339
// / Retrieve the descriptor path element at this depth.
1337
1340
auto &pathElement = descriptorPath[depth];
1338
- auto currentContext = pathElement.context ;
1339
1341
1340
1342
// Check whether the index is clearly out of bounds.
1341
- if (index >= currentContext-> getNumGenericParams () )
1343
+ if (index >= pathElement. numTotalGenericParams )
1342
1344
return nullptr ;
1343
1345
1344
1346
// Compute the flat index.
1345
1347
unsigned flatIndex = pathElement.numKeyGenericParamsInParent ;
1346
1348
if (pathElement.hasNonKeyGenericParams > 0 ) {
1347
1349
// We have non-key generic parameters at this level, so the index needs to
1348
1350
// be checked more carefully.
1349
- auto genericParams = getLocalGenericParams (currentContext) ;
1351
+ auto genericParams = pathElement. localGenericParams ;
1350
1352
1351
1353
// Make sure that the requested parameter itself has a key argument.
1352
1354
if (!genericParams[index].hasKeyArgument ())
@@ -1362,7 +1364,7 @@ SubstGenericParametersFromMetadata::operator()(
1362
1364
flatIndex += index;
1363
1365
}
1364
1366
1365
- return base-> getGenericArgs () [flatIndex];
1367
+ return ( const Metadata *)genericArgs [flatIndex];
1366
1368
}
1367
1369
1368
1370
const WitnessTable *
@@ -1371,8 +1373,7 @@ SubstGenericParametersFromMetadata::operator()(const Metadata *type,
1371
1373
// On first access, compute the descriptor path.
1372
1374
setup ();
1373
1375
1374
- return (const WitnessTable *)base->getGenericArgs ()[
1375
- index + numKeyGenericParameters];
1376
+ return (const WitnessTable *)genericArgs[index + numKeyGenericParameters];
1376
1377
}
1377
1378
1378
1379
const Metadata *SubstGenericParametersFromWrittenArgs::operator ()(
0 commit comments