@@ -1276,7 +1276,7 @@ _gatherGenericParameters(const ContextDescriptor *context,
1276
1276
auto generics = context->getGenericContext ();
1277
1277
assert (generics);
1278
1278
1279
- // If we have a parent, gather it's generic arguments "as written". If our
1279
+ // If we have a parent, gather its generic arguments "as written". If our
1280
1280
// parent is not generic, there are no generic arguments to add.
1281
1281
if (parent && parent->getTypeContextDescriptor () &&
1282
1282
parent->getTypeContextDescriptor ()->getGenericContext ()) {
@@ -3297,19 +3297,9 @@ bool swift::_gatherWrittenGenericParameters(
3297
3297
missingWrittenArguments = true ;
3298
3298
}
3299
3299
3300
- switch (param.getKind ()) {
3301
- case GenericParamKind::Type:
3302
- // Already handled by the above.
3303
- break ;
3304
-
3305
- case GenericParamKind::TypePack:
3306
- // Already handled by the above.
3307
- break ;
3308
-
3309
- default :
3310
- // We don't know about this kind of parameter.
3311
- return false ;
3312
- }
3300
+ assert ((param.getKind () == GenericParamKind::Type ||
3301
+ param.getKind () == GenericParamKind::TypePack) &&
3302
+ " Unknown generic parameter kind" );
3313
3303
}
3314
3304
3315
3305
// If there is no follow-up work to do, we're done.
@@ -3326,8 +3316,6 @@ bool swift::_gatherWrittenGenericParameters(
3326
3316
SubstGenericParametersFromWrittenArgs substitutions (genericArgs,
3327
3317
genericParamCounts);
3328
3318
3329
- bool needToCheckAssociatedSameTypes = false ;
3330
-
3331
3319
// Walk through the generic requirements to evaluate same-type
3332
3320
// constraints that are needed to fill in missing generic arguments.
3333
3321
for (const auto &req : genericContext->getGenericRequirements ()) {
@@ -3375,10 +3363,10 @@ bool swift::_gatherWrittenGenericParameters(
3375
3363
auto rhsParam = demangleToGenericParamRef (req.getMangledTypeName ());
3376
3364
3377
3365
// If the rhs parameter is not a generic parameter itself with
3378
- // (depth, index), it could potentially be some associated type. Check it
3379
- // again later once we've found all of the other same types.
3366
+ // (depth, index), it could potentially be some associated type. If that's
3367
+ // the case, then we don't need to do anything else for this rhs because it
3368
+ // won't appear in the key arguments list.
3380
3369
if (!rhsParam) {
3381
- needToCheckAssociatedSameTypes = true ;
3382
3370
continue ;
3383
3371
}
3384
3372
@@ -3394,58 +3382,6 @@ bool swift::_gatherWrittenGenericParameters(
3394
3382
genericArgs[*rhsFlatIndex] = genericArgs[*lhsFlatIndex];
3395
3383
}
3396
3384
3397
- if (!needToCheckAssociatedSameTypes) {
3398
- return true ;
3399
- }
3400
-
3401
- // Once again, loop through our list and look for same type constraints where
3402
- // the rhs is an associated type of sorts.
3403
- for (const auto &req : genericContext->getGenericRequirements ()) {
3404
- // We only care about same-type constraints.
3405
- if (req.Flags .getKind () != GenericRequirementKind::SameType) {
3406
- continue ;
3407
- }
3408
-
3409
- auto lhsParam = demangleToGenericParamRef (req.getParam ());
3410
-
3411
- if (!lhsParam) {
3412
- continue ;
3413
- }
3414
-
3415
- auto lhsFlatIndex =
3416
- _depthIndexToFlatIndex (lhsParam->first , lhsParam->second ,
3417
- genericParamCounts);
3418
- if (!lhsFlatIndex || *lhsFlatIndex >= genericArgs.size ())
3419
- return false ;
3420
-
3421
- auto rhsParam =
3422
- swift_getTypeByMangledName (MetadataState::Abstract,
3423
- req.getMangledTypeName (),
3424
- keyArgs.data (),
3425
- [&substitutions](unsigned depth, unsigned index) {
3426
- return substitutions.getMetadata (depth, index).Ptr ;
3427
- },
3428
- [&substitutions](const Metadata *type, unsigned index) {
3429
- return substitutions.getWitnessTable (type, index);
3430
- }).getType ().getMetadata ();
3431
-
3432
- if (!rhsParam) {
3433
- return false ;
3434
- }
3435
-
3436
- // If we already have an argument for the lhs, then just check that it is
3437
- // indeed == to the rhs type.
3438
- if (auto genericArg = genericArgs[*lhsFlatIndex]) {
3439
- if (genericArg.getMetadata () != rhsParam) {
3440
- return false ;
3441
- }
3442
- } else {
3443
- // If we don't have a lhs yet, then it's just the rhs.
3444
- genericArgs[*lhsFlatIndex] = MetadataOrPack (rhsParam);
3445
- }
3446
-
3447
- }
3448
-
3449
3385
return true ;
3450
3386
}
3451
3387
0 commit comments