Skip to content

Commit 1cc1541

Browse files
committed
[Associated type inference] Resolve @_implements on AsyncSequence.Failure
A source-compatibility hack to not resolve AsyncSequence.Failure via lookup accidentally disabled the `@_implements`-based lookup that we use to avoid having to run inference again in Swift textual interfaces. Tweak the logic here to narrow the source-compatibilty hack. Fixes rdar://125320522.
1 parent bd8ab16 commit 1cc1541

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

lib/Sema/AssociatedTypeInference.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)