Skip to content

AssociatedTypeInference: Make a cycle breaking hack more principled #82159

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

slavapestov
Copy link
Contributor

We would return an ErrorType without diagnosing anything from NormalProtocolConformance::getTypeWitnessAndDecl() to signal a transient condition to associated type inference. But other callers that receive an ErrorType don't expect that this can happen, and they in turn won't diagnose anything. So we'd end up in SILGen with a broken AST.

Instead, push the cycle break up into getWitnessTypeForMatching(), and remove the hack from getTypeWitnessAndDecl(). If someone else calls getTypeWitnessAndDecl() and that causes a request cycle, we will now diagnose the request cycle via the usual mechanism.

Fixes rdar://120388028.

@slavapestov slavapestov marked this pull request as draft June 10, 2025 19:23
We would return an ErrorType without diagnosing anything from
NormalProtocolConformance::getTypeWitnessAndDecl() to signal
a transient condition to associated type inference. But other
callers that receive an ErrorType don't expect that this can
happen, and they in turn won't diagnose anything. So we'd end
up in SILGen with a broken AST.

Instead, push the cycle break up into getWitnessTypeForMatching(),
and remove the hack from getTypeWitnessAndDecl(). If someone
else calls getTypeWitnessAndDecl() and that causes a request
cycle, we will now diagnose the request cycle via the usual
mechanism.

Fixes rdar://120388028.
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