@@ -430,13 +430,6 @@ static ResolveWitnessResult resolveTypeWitnessViaLookup(
430
430
auto *dc = conformance->getDeclContext ();
431
431
auto &ctx = dc->getASTContext ();
432
432
433
- // Prior to Swift 6, don't look for a named type witness for
434
- // AsyncSequence.Failure. We'll always infer it from
435
- // AsyncIteratorProtocol.Failure.
436
- if (isAsyncSequenceFailure (assocType) &&
437
- !ctx.LangOpts .isSwiftVersionAtLeast (6 ))
438
- return ResolveWitnessResult::Missing;
439
-
440
433
// Conformances constructed by the ClangImporter should have explicit type
441
434
// witnesses already.
442
435
if (isa<ClangModuleUnit>(dc->getModuleScopeContext ())) {
@@ -479,10 +472,18 @@ static ResolveWitnessResult resolveTypeWitnessViaLookup(
479
472
// Also skip candidates in protocol extensions, because they tend to cause
480
473
// request cycles. We'll look at those during associated type inference.
481
474
if (assocType->getName () != typeDecl->getName () &&
482
- !(witnessHasImplementsAttrForRequiredName (typeDecl, assocType) &&
475
+ !(witnessHasImplementsAttrForExactRequirement (typeDecl, assocType) &&
483
476
!typeDecl->getDeclContext ()->getSelfProtocolDecl ()))
484
477
continue ;
485
478
479
+ // Prior to Swift 6, ignore a member named Failure when matching
480
+ // AsyncSequence.Failure. We'll infer it from the AsyncIterator.Failure
481
+ // instead.
482
+ if (isAsyncSequenceFailure (assocType) &&
483
+ !ctx.LangOpts .isSwiftVersionAtLeast (6 ) &&
484
+ assocType->getName () == typeDecl->getName ())
485
+ continue ;;
486
+
486
487
auto *genericDecl = cast<GenericTypeDecl>(typeDecl);
487
488
488
489
// If the declaration has generic parameters, it cannot witness an
0 commit comments