Skip to content

[CS] Ensure DeclContext is switched for if/switch expressions #79420

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

Merged
merged 1 commit into from
Feb 17, 2025

Conversation

hamishknight
Copy link
Contributor

Similar to multi-statement closures, we need to make sure we change the DeclContext of the ConstraintSystem when solving a conjunction for an if/switch expression. This is unfortunately needed for cases within single-expression closures since they can't switch the system's DeclContext (as they're solved together with the rest of the system).

Resolves #79395

@hamishknight
Copy link
Contributor Author

@swift-ci please test

@hamishknight
Copy link
Contributor Author

@swift-ci please test source compatibility

Copy link
Contributor

@xedin xedin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should also do the same for Tap expressions

Similar to multi-statement closures, we need to
make sure we change the DeclContext of the
ConstraintSystem when solving a conjunction for an
if/switch expression. This is unfortunately needed
for cases within single-expression closures since
they can't switch the system's DeclContext (as
they're solved together with the rest of the system).
@hamishknight
Copy link
Contributor Author

@swift-ci please smoke test

@hamishknight
Copy link
Contributor Author

I think we should also do the same for Tap expressions

Heh, I was thinking about that, but couldn't think of a case that wouldn't also be problematic for single-expression closures in general. But yeah, no harm in doing it regardless :)

@hamishknight hamishknight merged commit 963889d into swiftlang:main Feb 17, 2025
3 checks passed
@hamishknight hamishknight deleted the more-context branch February 17, 2025 16:55
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.

Spurious access-control diagnostic for local type in if/switch expression nested in closure
2 participants