Skip to content

Conversation

DougGregor
Copy link
Member

When inferring a type witness for AsyncIteratorProtocol or AsyncSequence's Failure associated type, don't infer from a generic parameter named Failure. Instead, use next() as a cue: if it rethrows, use Failure from one of the conformances; if it throws, use any Error. This is a more conservative inference rule, and addresses a failure to infer a Failure type witness for some fairly-obvious cases.

Fixes rdar://122514816.

When inferring a type witness for `AsyncIteratorProtocol` or
`AsyncSequence`'s `Failure` associated type, don't infer from a
generic parameter named `Failure`. Instead, use `next()` as a cue: if
it `rethrows`, use `Failure` from one of the conformances; if it
`throws`, use `any Error`. This is a more conservative inference rule,
and addresses a failure to infer a `Failure` type witness for some
fairly-obvious cases.

Fixes rdar://122514816.
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

@swift-ci please test source compatibility

@DougGregor DougGregor merged commit c1c68d5 into swiftlang:main Feb 9, 2024
@DougGregor DougGregor deleted the failure-inference-failed branch February 9, 2024 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant