@@ -2269,7 +2269,7 @@ static void installGetClassHook() {
2269
2269
unsigned SubstGenericParametersFromMetadata::
2270
2270
buildDescriptorPath (const ContextDescriptor *context,
2271
2271
Demangler &borrowFrom) const {
2272
- assert (sourceIsMetadata );
2272
+ assert (sourceKind == SourceKind::Metadata );
2273
2273
2274
2274
// Terminating condition: we don't have a context.
2275
2275
if (!context)
@@ -2360,20 +2360,76 @@ buildEnvironmentPath(
2360
2360
return totalKeyParamCount;
2361
2361
}
2362
2362
2363
+ unsigned SubstGenericParametersFromMetadata::buildShapePath (
2364
+ const TargetExtendedExistentialTypeShape<InProcess> *shape) const {
2365
+ unsigned totalParamCount = 0 ;
2366
+ unsigned totalKeyParamCount = 0 ;
2367
+
2368
+ auto genSig = shape->getGeneralizationSignature ();
2369
+ if (!genSig.getParams ().empty ()) {
2370
+ bool hasNonKeyGenericParams = false ;
2371
+ unsigned numKeyGenericParamsHere = 0 ;
2372
+ for (const auto &gp : genSig.getParams ()) {
2373
+ if (gp.hasKeyArgument ())
2374
+ numKeyGenericParamsHere++;
2375
+ else
2376
+ hasNonKeyGenericParams = true ;
2377
+ }
2378
+ totalParamCount += numKeyGenericParamsHere;
2379
+ totalKeyParamCount += numKeyGenericParamsHere;
2380
+ descriptorPath.push_back (PathElement{genSig.getParams (), totalParamCount,
2381
+ /* numKeyGenericParamsInParent*/ 0 ,
2382
+ numKeyGenericParamsHere,
2383
+ hasNonKeyGenericParams});
2384
+ }
2385
+
2386
+ const unsigned genSigParamCount = genSig.getParams ().size ();
2387
+ auto reqSig = shape->getRequirementSignature ();
2388
+ assert (reqSig.getParams ().size () > genSig.getParams ().size ());
2389
+ {
2390
+ bool hasNonKeyGenericParams = false ;
2391
+ unsigned numKeyGenericParamsHere = 0 ;
2392
+ auto remainingParams = reqSig.getParams ().drop_front (genSig.getParams ().size ());
2393
+ for (const auto &gp : remainingParams) {
2394
+ if (gp.hasKeyArgument ())
2395
+ numKeyGenericParamsHere++;
2396
+ else
2397
+ hasNonKeyGenericParams = true ;
2398
+ }
2399
+ totalParamCount += numKeyGenericParamsHere;
2400
+ totalKeyParamCount += numKeyGenericParamsHere;
2401
+ descriptorPath.push_back (PathElement{remainingParams,
2402
+ totalParamCount,
2403
+ genSigParamCount,
2404
+ numKeyGenericParamsHere,
2405
+ hasNonKeyGenericParams});
2406
+ }
2407
+
2408
+ return totalKeyParamCount;
2409
+ }
2410
+
2363
2411
void SubstGenericParametersFromMetadata::setup () const {
2364
2412
if (!descriptorPath.empty ())
2365
2413
return ;
2366
2414
2367
- if (sourceIsMetadata && baseContext) {
2415
+ switch (sourceKind) {
2416
+ case SourceKind::Metadata: {
2417
+ assert (baseContext);
2368
2418
DemanglerForRuntimeTypeResolution<StackAllocatedDemangler<2048 >> demangler;
2369
2419
numKeyGenericParameters = buildDescriptorPath (baseContext, demangler);
2370
2420
return ;
2371
2421
}
2372
-
2373
- if (!sourceIsMetadata && environment) {
2422
+ case SourceKind::Environment: {
2423
+ assert ( environment);
2374
2424
numKeyGenericParameters = buildEnvironmentPath (environment);
2375
2425
return ;
2376
2426
}
2427
+ case SourceKind::Shape: {
2428
+ assert (shape);
2429
+ numKeyGenericParameters = buildShapePath (shape);
2430
+ return ;
2431
+ }
2432
+ }
2377
2433
}
2378
2434
2379
2435
const Metadata *
0 commit comments