Skip to content

[Sema] Remove RecontextualizeClosures #78367

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 6 commits into from
Jan 7, 2025

Conversation

hamishknight
Copy link
Contributor

@hamishknight hamishknight commented Dec 26, 2024

Merge with ContextualizeClosuresAndMacros, and rename to ContextualizationWalker given that it re-contextualizes a whole bunch of AST nodes now. This ensures we correctly handle cases such as decls in if/switch expressions within autoclosures.

Resolves #75294
rdar://131973802

We want to walk the lazy initializer in the
accessor, but when this code was written that
wasn't a walking option. Switch to using
`LazyInitializerWalking::InAccessor`.
Expose a generic `TypeChecker::contextualizeExpr`
to invoke it.
We want these to be contextualized as part of
their implicit getter, avoid attempting to
contextualize as part of the PatternBindingDecl.
This avoid incorrectly computing captures as part
of the PatternBindingDecl; as such we also need
to update ActorIsolationChecker to walk lazy inits
as part of the accessor.
Merge with ContextualizeClosuresAndMacros, and
rename to ContextualizationWalker given that it
re-contextualizes a whole bunch of AST nodes now.
This ensures we correctly handle cases such as
decls in if/switch expressions within autoclosures.
If the decl itself is a DeclContext, make sure to
update its parent too.
Make sure we walk into any non-DeclContext decl,
allowing us to e.g walk into VarDecls to correctly
re-contextualize their accessors in an outer
autoclosure. I don't *think* this currently makes
much of a difference since the mangling today uses
the DeclContext of the VarDecl, but it seems like
the right thing to do regardless.
@hamishknight
Copy link
Contributor Author

@swift-ci please test source compatibility

@hamishknight hamishknight marked this pull request as ready for review December 30, 2024 16:28
@hamishknight
Copy link
Contributor Author

@swift-ci please test

@hamishknight hamishknight merged commit 33bff48 into swiftlang:main Jan 7, 2025
6 of 7 checks passed
@hamishknight hamishknight deleted the in-context branch January 7, 2025 09:43
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.

Crash when compiling async let body with if expression
2 participants