@@ -3804,7 +3804,7 @@ filterProtocolRequirements(
3804
3804
3805
3805
// / Prune the set of missing witnesses for the given conformance, eliminating
3806
3806
// / any requirements that do not actually need to satisfied.
3807
- static ArrayRef<MissingWitness> pruneMissingWitnesses ( // FIXME: this does not remove the missing witness note here!!!
3807
+ static ArrayRef<MissingWitness> pruneMissingWitnesses (
3808
3808
ConformanceChecker &checker,
3809
3809
ProtocolDecl *proto,
3810
3810
NormalProtocolConformance *conformance,
@@ -3814,14 +3814,6 @@ static ArrayRef<MissingWitness> pruneMissingWitnesses( // FIXME: this does not r
3814
3814
return missingWitnesses;
3815
3815
}
3816
3816
3817
- // For an @objc protocol defined in Objective-C, the Clang importer might
3818
- // have imported the same underlying Objective-C declaration as more than
3819
- // one Swift declaration. If we aren't in an imported @objc protocol, there
3820
- // is nothing to do.
3821
- if (!proto->isObjC ()) {
3822
- return missingWitnesses;
3823
- }
3824
-
3825
3817
// Consider each of the missing witnesses to remove any that should not
3826
3818
// longer be considered "missing".
3827
3819
llvm::SmallDenseSet<ConformanceChecker::ObjCMethodKey>
@@ -3857,30 +3849,46 @@ static ArrayRef<MissingWitness> pruneMissingWitnesses( // FIXME: this does not r
3857
3849
continue ;
3858
3850
}
3859
3851
3852
+ // For an @objc protocol defined in Objective-C, the Clang importer might
3853
+ // have imported the same underlying Objective-C declaration as more than
3854
+ // one Swift declaration. Only one of those requirements should be witnessed
3855
+ // so if the requirement sibling is witnessed then this requirement is not
3856
+ // missing.
3857
+
3858
+ // Prune requirements that come from other protocols - we don't want to
3859
+ // attempt to diagnose those here since we won't be able to find their
3860
+ // siblings.
3861
+ if (proto != missingWitness.requirement ->getDeclContext ()->getAsDecl ()) {
3862
+ skipWitness ();
3863
+ continue ;
3864
+ }
3865
+
3866
+ if (!proto->isObjC ()) {
3867
+ addWitness ();
3868
+ continue ;
3869
+ }
3870
+
3860
3871
auto fnRequirement = cast<AbstractFunctionDecl>(missingWitness.requirement );
3861
3872
auto key = checker.getObjCMethodKey (fnRequirement);
3862
3873
3863
- // If we have already reported a function with this selector as missing,
3864
- // don't do it again.
3865
- if (alreadyReportedAsMissing.count (key)) {
3874
+ if (checker.getObjCRequirementSibling (
3875
+ fnRequirement, [conformance](AbstractFunctionDecl *candidate) {
3876
+ return static_cast <bool >(conformance->getWitness (candidate));
3877
+ })) {
3866
3878
skipWitness ();
3867
3879
continue ;
3868
3880
}
3869
3881
3870
- auto sibling = checker.getObjCRequirementSibling (
3871
- fnRequirement, [conformance](AbstractFunctionDecl *candidate) {
3872
- return static_cast <bool >(conformance->getWitness (candidate));
3873
- });
3874
-
3875
- if (!sibling) {
3876
- alreadyReportedAsMissing.insert (key);
3877
- addWitness ();
3882
+ // If we have already reported a function with this selector as missing,
3883
+ // don't do it again.
3884
+ if (alreadyReportedAsMissing.count (key)) {
3885
+ skipWitness ();
3878
3886
continue ;
3879
3887
}
3880
3888
3881
- // Otherwise, there is a witness for any of the *other* requirements with
3882
- // this same selector, so prune it out.
3883
- skipWitness ();
3889
+ // There is really a missing requirement for this witness.
3890
+ alreadyReportedAsMissing. insert (key);
3891
+ addWitness ();
3884
3892
}
3885
3893
3886
3894
if (removedAny) {
@@ -5402,22 +5410,6 @@ void ConformanceChecker::resolveValueWitnesses() {
5402
5410
continue ;
5403
5411
}
5404
5412
5405
- // If this requirement is part of a pair of imported async requirements,
5406
- // where one has already been witnessed, we can skip it.
5407
- //
5408
- // This situation primarily arises when the ClangImporter translates an
5409
- // async-looking ObjC protocol method requirement into two Swift protocol
5410
- // requirements: an async version and a sync version. Exactly one of the two
5411
- // must be witnessed by the conformer.
5412
- if (!requirement->isImplicit () && getObjCRequirementSibling (
5413
- requirement, [this ](AbstractFunctionDecl *cand) {
5414
- return !cand->getAttrs ().hasAttribute <OptionalAttr>() &&
5415
- !cand->isImplicit () &&
5416
- this ->Conformance ->hasWitness (cand);
5417
- })) {
5418
- continue ;
5419
- }
5420
-
5421
5413
// Try substituting into the requirement's interface type. If we fail,
5422
5414
// either a generic requirement was not satisfied or we tripped on an
5423
5415
// invalid type witness, and there's no point in resolving a witness.
0 commit comments