@@ -3368,9 +3368,8 @@ static bool usesFeatureFlowSensitiveConcurrencyCaptures(Decl *decl) {
3368
3368
// / \param isRelevantInverse the function used to inspect a mark corresponding
3369
3369
// / to an inverse to determine whether it "has" an inverse that we care about.
3370
3370
static bool hasInverse (
3371
- Decl *decl,
3372
- InvertibleProtocolKind ip,
3373
- std::function<bool (InverseMarking const &)> isRelevantInverse) {
3371
+ Decl *decl, InvertibleProtocolKind ip,
3372
+ std::function<bool (InverseMarking::Mark const &)> isRelevantInverse) {
3374
3373
3375
3374
auto getTypeDecl = [](Type type) -> TypeDecl* {
3376
3375
if (auto genericTy = type->getAnyGeneric ())
@@ -3382,38 +3381,22 @@ static bool hasInverse(
3382
3381
3383
3382
if (auto *extension = dyn_cast<ExtensionDecl>(decl)) {
3384
3383
if (auto *nominal = extension->getSelfNominalTypeDecl ())
3385
- if (isRelevantInverse (nominal->getMarking (ip)))
3386
- return true ;
3384
+ return hasInverse (nominal, ip, isRelevantInverse);
3387
3385
}
3388
3386
3389
- if (auto typeDecl = dyn_cast<TypeDecl>(decl)) {
3390
- if (isRelevantInverse (typeDecl->getMarking (ip)))
3391
- return true ;
3392
-
3393
- // Check the protocol's associated types too.
3394
- if (auto proto = dyn_cast<ProtocolDecl>(decl)) {
3395
- auto hasInverse =
3396
- llvm::any_of (proto->getAssociatedTypeMembers (),
3397
- [&](AssociatedTypeDecl *assocTyDecl) {
3398
- return isRelevantInverse (assocTyDecl->getMarking (ip));
3399
- });
3400
- if (hasInverse)
3401
- return true ;
3402
- }
3403
- }
3387
+ if (auto *TD = dyn_cast<TypeDecl>(decl))
3388
+ return isRelevantInverse (TD->hasInverseMarking (ip));
3404
3389
3405
3390
if (auto value = dyn_cast<ValueDecl>(decl)) {
3406
3391
// Check for noncopyable types in the types of this declaration.
3407
3392
if (Type type = value->getInterfaceType ()) {
3408
- bool hasInverse = type.findIf ([&](Type type) {
3393
+ bool foundInverse = type.findIf ([&](Type type) -> bool {
3409
3394
if (auto *typeDecl = getTypeDecl (type))
3410
- if (isRelevantInverse (typeDecl->getMarking (ip)))
3411
- return true ;
3412
-
3395
+ return hasInverse (typeDecl, ip, isRelevantInverse);
3413
3396
return false ;
3414
3397
});
3415
3398
3416
- if (hasInverse )
3399
+ if (foundInverse )
3417
3400
return true ;
3418
3401
}
3419
3402
}
@@ -3424,8 +3407,8 @@ static bool hasInverse(
3424
3407
static bool usesFeatureMoveOnly (Decl *decl) {
3425
3408
return hasInverse (decl, InvertibleProtocolKind::Copyable,
3426
3409
[](auto &marking) -> bool {
3427
- return marking. getInverse () .is (InverseMarking::Kind::LegacyExplicit);
3428
- });
3410
+ return marking.is (InverseMarking::Kind::LegacyExplicit);
3411
+ });
3429
3412
}
3430
3413
3431
3414
static bool usesFeatureLazyImmediate (Decl *D) { return false ; }
@@ -3469,8 +3452,8 @@ static bool usesFeatureMoveOnlyPartialReinitialization(Decl *decl) {
3469
3452
}
3470
3453
3471
3454
static bool usesFeatureNoncopyableGenerics (Decl *decl) {
3472
- auto checkMarking = [](auto &marking) -> bool {
3473
- switch (marking.getInverse (). getKind ()) {
3455
+ auto checkInverseMarking = [](auto &marking) -> bool {
3456
+ switch (marking.getKind ()) {
3474
3457
case InverseMarking::Kind::None:
3475
3458
case InverseMarking::Kind::LegacyExplicit: // covered by other checks.
3476
3459
return false ;
@@ -3481,8 +3464,10 @@ static bool usesFeatureNoncopyableGenerics(Decl *decl) {
3481
3464
}
3482
3465
};
3483
3466
3484
- return hasInverse (decl, InvertibleProtocolKind::Copyable, checkMarking)
3485
- || hasInverse (decl, InvertibleProtocolKind::Escapable, checkMarking);
3467
+ return hasInverse (decl, InvertibleProtocolKind::Copyable,
3468
+ checkInverseMarking) ||
3469
+ hasInverse (decl, InvertibleProtocolKind::Escapable,
3470
+ checkInverseMarking);
3486
3471
}
3487
3472
3488
3473
static bool usesFeatureOneWayClosureParameters (Decl *decl) {
0 commit comments