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