@@ -6726,21 +6726,6 @@ NominalTypeDecl::hasInverseMarking(InvertibleProtocolKind target) const {
6726
6726
return false ;
6727
6727
};
6728
6728
6729
- auto resolveRequirement = [&](unsigned reqIdx) -> std::optional<Requirement> {
6730
- WhereClauseOwner owner (const_cast <NominalTypeDecl *>(this ));
6731
- auto req = ctx.evaluator (
6732
- RequirementRequest{owner, reqIdx, TypeResolutionStage::Structural},
6733
- [&]() {
6734
- return Requirement (RequirementKind::SameType, ErrorType::get (ctx),
6735
- ErrorType::get (ctx));
6736
- });
6737
-
6738
- if (req.hasError ())
6739
- return std::nullopt;
6740
-
6741
- return req;
6742
- };
6743
-
6744
6729
llvm::SmallSet<GenericTypeParamDecl *, 4 > params;
6745
6730
6746
6731
// Scan the inheritance clauses of generic parameters only for an inverse.
@@ -6765,28 +6750,23 @@ NominalTypeDecl::hasInverseMarking(InvertibleProtocolKind target) const {
6765
6750
if (requirementRepr.getKind () != RequirementReprKind::TypeConstraint)
6766
6751
continue ;
6767
6752
6768
- auto *constraintRepr =
6769
- dyn_cast<InverseTypeRepr>(requirementRepr.getConstraintRepr ());
6770
- if (!constraintRepr || constraintRepr->isInvalid ())
6771
- continue ;
6772
-
6773
- auto req = resolveRequirement (i);
6774
- if (!req)
6775
- continue ;
6753
+ auto *subjectRepr =
6754
+ dyn_cast<IdentTypeRepr>(requirementRepr.getSubjectRepr ());
6776
6755
6777
- if (req-> getKind () != RequirementKind::Conformance )
6756
+ if (!(subjectRepr && subjectRepr-> isBound ()) )
6778
6757
continue ;
6779
6758
6780
- auto subject = req->getFirstType ();
6781
- if (!subject->isTypeParameter ())
6759
+ auto *subjectGP =
6760
+ dyn_cast<GenericTypeParamDecl>(subjectRepr->getBoundDecl ());
6761
+ if (!subjectGP || !params.contains (subjectGP))
6782
6762
continue ;
6783
6763
6784
- // Skip outer params and implicit ones.
6785
- auto *param = subject-> getRootGenericParam ()-> getDecl ( );
6786
- if (!param || !params. contains (param ))
6764
+ auto *constraintRepr =
6765
+ dyn_cast<InverseTypeRepr>(requirementRepr. getConstraintRepr () );
6766
+ if (!constraintRepr || constraintRepr-> isInvalid ( ))
6787
6767
continue ;
6788
6768
6789
- if (isInverseTarget (req-> getSecondType ()))
6769
+ if (constraintRepr-> isInverseOf (target, getDeclContext ()))
6790
6770
return InverseMarking::Mark (InverseMarking::Kind::Inferred,
6791
6771
constraintRepr->getLoc ());
6792
6772
}
0 commit comments