-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Skip setting type expansion context for captures of skipped functions #70835
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
Conversation
@BradLarson could you please kick off swift-ci? |
I’m not sure I understand why. These functions cannot be referenced so why do we need their captures when skipping bodies? |
You're right. I was initially going off of the function SILGen invariants you established in this commit. But if a function's body is never going to be emitted then I don't see any reason why we would need their captures. One incorrect assumption that I made initially was that this capture info is represented in the "function signatures" on top of a SIL file. But, those are swift signatures. I think the fix should be to simply not set the type expansion context for captures here based on whether or not the function body is going to be emitted? |
Type-checking and SILGen for non-inlinable functions is skipped in the presence of `-experimental-skip-non-inlinable-function-bodies` and `-experimental-skip-non-inlinable-function-bodies-without-types` flags. Such functions may be top-level and may contain captures (if they appear after a `guard` statement), for which we were setting the type expansion context during SILGen. Setting type expansion context however, relied on the capture info being computed -- which was never happening because of the abovementioned flags. Changes in this commit make setting type expansion context, for captures, conditional on a flag that ensures that the function has already been typechecked. Fixes swiftlang#57646
@slavapestov could you please take a look at this? |
@swift-ci Please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
@slavapestov Is there anything else needed to merge this? Or are we waiting on more approvals? |
Type-checking and SILGen for non-inlinable functions is skipped in the presence of
-experimental-skip-non-inlinable-function-bodies
and-experimental-skip-non-inlinable-function-bodies-without-types
flags.Such functions may be top-level and may contain captures (if they appear after a
guard
statement), for which we were setting the type expansion context during SILGen. Setting type expansion context however, relied on the capture info being computed -- which was never happening because of the abovementioned flags.Changes in this commit make setting type expansion context, for captures, conditional on a flag that ensures that the function has already been typechecked.
Fixes #57646