@@ -4901,6 +4901,14 @@ GenericParameterReferenceInfo ValueDecl::findExistentialSelfReferences(
49014901 llvm::None);
49024902}
49034903
4904+ InverseMarking::Mark
4905+ TypeDecl::hasInverseMarking (InvertibleProtocolKind target) const {
4906+ if (auto P = dyn_cast<ProtocolDecl>(this ))
4907+ return P->hasInverseMarking (target);
4908+
4909+ return getMarking (target).getInverse ();
4910+ }
4911+
49044912InverseMarking TypeDecl::getMarking (InvertibleProtocolKind ip) const {
49054913 return evaluateOrDefault (
49064914 getASTContext ().evaluator ,
@@ -6614,13 +6622,13 @@ bool ProtocolDecl::inheritsFrom(const ProtocolDecl *super) const {
66146622 });
66156623}
66166624
6617- std::pair< /* found= */ bool , /* where= */ SourceLoc>
6625+ InverseMarking::Mark
66186626ProtocolDecl::hasInverseMarking (InvertibleProtocolKind target) const {
66196627 auto &ctx = getASTContext ();
66206628
66216629 // Legacy support stops here.
66226630 if (!ctx.LangOpts .hasFeature (Feature::NoncopyableGenerics))
6623- return std::make_pair ( false , SourceLoc () );
6631+ return InverseMarking::Mark ( );
66246632
66256633 auto inheritedTypes = getInherited ();
66266634 for (unsigned i = 0 ; i < inheritedTypes.size (); ++i) {
@@ -6634,13 +6642,14 @@ ProtocolDecl::hasInverseMarking(InvertibleProtocolKind target) const {
66346642 if (auto *composition = type->getAs <ProtocolCompositionType>()) {
66356643 // Found ~<target> in the protocol inheritance clause.
66366644 if (composition->getInverses ().contains (target))
6637- return std::make_pair (true , repr ? repr->getLoc () : SourceLoc ());
6645+ return InverseMarking::Mark (InverseMarking::Kind::Explicit,
6646+ repr ? repr->getLoc () : SourceLoc ());
66386647 }
66396648 }
66406649
66416650 auto *whereClause = getTrailingWhereClause ();
66426651 if (!whereClause)
6643- return std::make_pair ( false , SourceLoc () );
6652+ return InverseMarking::Mark ( );
66446653
66456654 for (const auto &reqRepr : whereClause->getRequirements ()) {
66466655 if (reqRepr.isInvalid () ||
@@ -6654,10 +6663,11 @@ ProtocolDecl::hasInverseMarking(InvertibleProtocolKind target) const {
66546663 continue ;
66556664
66566665 if (constraintRepr->isInverseOf (target, getDeclContext ()))
6657- return std::make_pair (true , constraintRepr->getLoc ());
6666+ return InverseMarking::Mark (InverseMarking::Kind::Explicit,
6667+ constraintRepr->getLoc ());
66586668 }
66596669
6660- return std::make_pair ( false , SourceLoc () );
6670+ return InverseMarking::Mark ( );
66616671}
66626672
66636673bool ProtocolDecl::requiresInvertible (InvertibleProtocolKind ip) const {
@@ -6689,7 +6699,7 @@ bool ProtocolDecl::requiresInvertible(InvertibleProtocolKind ip) const {
66896699 // Otherwise, check to see if there's an inverse on this protocol.
66906700
66916701 // The implicit requirement was suppressed on this protocol, keep looking.
6692- if (proto->hasInverseMarking (ip). first )
6702+ if (proto->hasInverseMarking (ip))
66936703 return TypeWalker::Action::Continue;
66946704
66956705 return TypeWalker::Action::Stop; // No inverse, so implicitly inherited.
0 commit comments