Skip to content

Commit aa3feae

Browse files
committed
Sema: Skip missing async requirements of Obj-C protocols consistently.
Requirements of Obj-C protocols that take a completion handler get imported with an `async` sibling requirement which can be fulfilled instead. Exactly one of these two requirements should be fulfilled. When resolving value witnesses ad-hoc, the compiler would only skip diagnosing a missing witness of an async requirement if the sibling requirement were fulfilled and there were zero viable matches. It shouldn't matter how many viable matches there are, though, since the alternative requirement is already witnessed. There is no test case yet because when this problem reproduces, an assertion about resolving a witness after conformance checking is "complete" fails. A more significant overhaul of this logic should come later, but short-term we must fix source compatibility. Resolves rdar://124145619
1 parent c705a62 commit aa3feae

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4391,11 +4391,12 @@ ConformanceChecker::resolveWitnessViaLookup(ValueDecl *requirement) {
43914391
return ResolveWitnessResult::ExplicitFailed;
43924392
}
43934393

4394+
if (!shouldRecordMissingWitness(Proto, Conformance, requirement))
4395+
return ResolveWitnessResult::Missing;
43944396

43954397
if (!numViable) {
43964398
// Save the missing requirement for later diagnosis.
4397-
if (shouldRecordMissingWitness(Proto, Conformance, requirement))
4398-
getASTContext().addDelayedMissingWitness(Conformance, {requirement, matches});
4399+
getASTContext().addDelayedMissingWitness(Conformance, {requirement, matches});
43994400
return ResolveWitnessResult::Missing;
44004401
}
44014402

0 commit comments

Comments
 (0)