@@ -4901,6 +4901,14 @@ GenericParameterReferenceInfo ValueDecl::findExistentialSelfReferences(
4901
4901
llvm::None);
4902
4902
}
4903
4903
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
+
4904
4912
InverseMarking TypeDecl::getMarking (InvertibleProtocolKind ip) const {
4905
4913
return evaluateOrDefault (
4906
4914
getASTContext ().evaluator ,
@@ -6614,13 +6622,13 @@ bool ProtocolDecl::inheritsFrom(const ProtocolDecl *super) const {
6614
6622
});
6615
6623
}
6616
6624
6617
- std::pair< /* found= */ bool , /* where= */ SourceLoc>
6625
+ InverseMarking::Mark
6618
6626
ProtocolDecl::hasInverseMarking (InvertibleProtocolKind target) const {
6619
6627
auto &ctx = getASTContext ();
6620
6628
6621
6629
// Legacy support stops here.
6622
6630
if (!ctx.LangOpts .hasFeature (Feature::NoncopyableGenerics))
6623
- return std::make_pair ( false , SourceLoc () );
6631
+ return InverseMarking::Mark ( );
6624
6632
6625
6633
auto inheritedTypes = getInherited ();
6626
6634
for (unsigned i = 0 ; i < inheritedTypes.size (); ++i) {
@@ -6634,13 +6642,14 @@ ProtocolDecl::hasInverseMarking(InvertibleProtocolKind target) const {
6634
6642
if (auto *composition = type->getAs <ProtocolCompositionType>()) {
6635
6643
// Found ~<target> in the protocol inheritance clause.
6636
6644
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 ());
6638
6647
}
6639
6648
}
6640
6649
6641
6650
auto *whereClause = getTrailingWhereClause ();
6642
6651
if (!whereClause)
6643
- return std::make_pair ( false , SourceLoc () );
6652
+ return InverseMarking::Mark ( );
6644
6653
6645
6654
for (const auto &reqRepr : whereClause->getRequirements ()) {
6646
6655
if (reqRepr.isInvalid () ||
@@ -6654,10 +6663,11 @@ ProtocolDecl::hasInverseMarking(InvertibleProtocolKind target) const {
6654
6663
continue ;
6655
6664
6656
6665
if (constraintRepr->isInverseOf (target, getDeclContext ()))
6657
- return std::make_pair (true , constraintRepr->getLoc ());
6666
+ return InverseMarking::Mark (InverseMarking::Kind::Explicit,
6667
+ constraintRepr->getLoc ());
6658
6668
}
6659
6669
6660
- return std::make_pair ( false , SourceLoc () );
6670
+ return InverseMarking::Mark ( );
6661
6671
}
6662
6672
6663
6673
bool ProtocolDecl::requiresInvertible (InvertibleProtocolKind ip) const {
@@ -6689,7 +6699,7 @@ bool ProtocolDecl::requiresInvertible(InvertibleProtocolKind ip) const {
6689
6699
// Otherwise, check to see if there's an inverse on this protocol.
6690
6700
6691
6701
// The implicit requirement was suppressed on this protocol, keep looking.
6692
- if (proto->hasInverseMarking (ip). first )
6702
+ if (proto->hasInverseMarking (ip))
6693
6703
return TypeWalker::Action::Continue;
6694
6704
6695
6705
return TypeWalker::Action::Stop; // No inverse, so implicitly inherited.
0 commit comments