Skip to content

Conversation

@DougGregor
Copy link
Member

One can overload on async vs. non-async, and the constraint solver has a
preference rule based on context. Extend that preference rule to
witness matching, so we prefer a witness that exactly matches the
effects of the requirement to one that has fewer effects.

Fixes rdar://84034057.

@DougGregor
Copy link
Member Author

@swift-ci please smoke test

…ffects.

One can overload on async vs. non-async, and the constraint solver has a
preference rule based on context. Extend that preference rule to
witness matching, so we prefer a witness that exactly matches the
effects of the requirement to one that has fewer effects.

Fixes rdar://84034057.
@DougGregor DougGregor force-pushed the async-witness-matching-resolution branch from 3f2a9a5 to 293e316 Compare November 9, 2021 00:37
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor DougGregor merged commit 546f22a into swiftlang:main Nov 9, 2021
@DougGregor DougGregor deleted the async-witness-matching-resolution branch November 9, 2021 04:45
kavon added a commit to kavon/swift that referenced this pull request May 12, 2023
You can overload a function based on its `async`-ness, and
resolution is carried out based on async-ness of calling
context.

But during protocol conformance checking, for an `async`
requirement we were accidentally choosing the non-`async
overload instead of the `async` one. The `async` one is
the choice people would expect, since the `async` requirement
is in essence the "context" that forwards to the underlying
witness. This intended behavior is also inferred from:

swiftlang#40088

The problem boiled down to a bad check when categorizing the
witness matches prior to ranking them.

Resolves rdar://109135488 / swiftlang#60318
meg-gupta pushed a commit to meg-gupta/swift that referenced this pull request May 22, 2023
You can overload a function based on its `async`-ness, and
resolution is carried out based on async-ness of calling
context.

But during protocol conformance checking, for an `async`
requirement we were accidentally choosing the non-`async
overload instead of the `async` one. The `async` one is
the choice people would expect, since the `async` requirement
is in essence the "context" that forwards to the underlying
witness. This intended behavior is also inferred from:

swiftlang#40088

The problem boiled down to a bad check when categorizing the
witness matches prior to ranking them.

Resolves rdar://109135488 / swiftlang#60318
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