@@ -430,13 +430,6 @@ static ResolveWitnessResult resolveTypeWitnessViaLookup(
430430 auto *dc = conformance->getDeclContext ();
431431 auto &ctx = dc->getASTContext ();
432432
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-
440433 // Conformances constructed by the ClangImporter should have explicit type
441434 // witnesses already.
442435 if (isa<ClangModuleUnit>(dc->getModuleScopeContext ())) {
@@ -479,10 +472,18 @@ static ResolveWitnessResult resolveTypeWitnessViaLookup(
479472 // Also skip candidates in protocol extensions, because they tend to cause
480473 // request cycles. We'll look at those during associated type inference.
481474 if (assocType->getName () != typeDecl->getName () &&
482- !(witnessHasImplementsAttrForRequiredName (typeDecl, assocType) &&
475+ !(witnessHasImplementsAttrForExactRequirement (typeDecl, assocType) &&
483476 !typeDecl->getDeclContext ()->getSelfProtocolDecl ()))
484477 continue ;
485478
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+
486487 auto *genericDecl = cast<GenericTypeDecl>(typeDecl);
487488
488489 // If the declaration has generic parameters, it cannot witness an
0 commit comments