@@ -3368,9 +3368,8 @@ static bool usesFeatureFlowSensitiveConcurrencyCaptures(Decl *decl) {
33683368// / \param isRelevantInverse the function used to inspect a mark corresponding
33693369// / to an inverse to determine whether it "has" an inverse that we care about.
33703370static 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) {
33743373
33753374 auto getTypeDecl = [](Type type) -> TypeDecl* {
33763375 if (auto genericTy = type->getAnyGeneric ())
@@ -3382,38 +3381,22 @@ static bool hasInverse(
33823381
33833382 if (auto *extension = dyn_cast<ExtensionDecl>(decl)) {
33843383 if (auto *nominal = extension->getSelfNominalTypeDecl ())
3385- if (isRelevantInverse (nominal->getMarking (ip)))
3386- return true ;
3384+ return hasInverse (nominal, ip, isRelevantInverse);
33873385 }
33883386
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));
34043389
34053390 if (auto value = dyn_cast<ValueDecl>(decl)) {
34063391 // Check for noncopyable types in the types of this declaration.
34073392 if (Type type = value->getInterfaceType ()) {
3408- bool hasInverse = type.findIf ([&](Type type) {
3393+ bool foundInverse = type.findIf ([&](Type type) -> bool {
34093394 if (auto *typeDecl = getTypeDecl (type))
3410- if (isRelevantInverse (typeDecl->getMarking (ip)))
3411- return true ;
3412-
3395+ return hasInverse (typeDecl, ip, isRelevantInverse);
34133396 return false ;
34143397 });
34153398
3416- if (hasInverse )
3399+ if (foundInverse )
34173400 return true ;
34183401 }
34193402 }
@@ -3424,8 +3407,8 @@ static bool hasInverse(
34243407static bool usesFeatureMoveOnly (Decl *decl) {
34253408 return hasInverse (decl, InvertibleProtocolKind::Copyable,
34263409 [](auto &marking) -> bool {
3427- return marking. getInverse () .is (InverseMarking::Kind::LegacyExplicit);
3428- });
3410+ return marking.is (InverseMarking::Kind::LegacyExplicit);
3411+ });
34293412}
34303413
34313414static bool usesFeatureLazyImmediate (Decl *D) { return false ; }
@@ -3469,8 +3452,8 @@ static bool usesFeatureMoveOnlyPartialReinitialization(Decl *decl) {
34693452}
34703453
34713454static 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 ()) {
34743457 case InverseMarking::Kind::None:
34753458 case InverseMarking::Kind::LegacyExplicit: // covered by other checks.
34763459 return false ;
@@ -3481,8 +3464,10 @@ static bool usesFeatureNoncopyableGenerics(Decl *decl) {
34813464 }
34823465 };
34833466
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);
34863471}
34873472
34883473static bool usesFeatureOneWayClosureParameters (Decl *decl) {
0 commit comments