Skip to content

[6.2] Fix deserialization of lifetime dependencies on ast function types #81917

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
Jun 3, 2025

Conversation

meg-gupta
Copy link
Contributor

@meg-gupta meg-gupta commented Jun 2, 2025

Explanation: While deserializing AST function types FunctionType and GenericFunctionType which include lifetime dependencies and an implicit self parameter, we don't correctly populate ASTExtInfoBuilder.lifetimeDependencies. We end up reading one dependency less due to incorrect index calculation.

Unlike SILFunctionType, AST function types FunctionType and GenericFunctionType do not include implicit self in their param list. They represent methods with implicit self as: (Self) -> (Args...) -> Result and don't have any information to indicate they may have implicit self. Since we use number of parameters while deserializing lifetime dependencies, we go wrong for such function types.

Serialize the length of parameter indices, so that lifetime dependencies can be deserialized to that length.

Scope: Affects ~Escapable types

Testing: Added test involving conditionally ~Escapable Result

Risk: Low

Issue: rdar://151768216

Main PR: #81879

Reviewer: @atrick

@meg-gupta meg-gupta force-pushed the fixdeserializationcp branch from 5b39c5c to a5ce5b7 Compare June 2, 2025 23:31
@meg-gupta meg-gupta requested a review from tbkka June 2, 2025 23:31
@meg-gupta meg-gupta marked this pull request as ready for review June 2, 2025 23:31
@meg-gupta meg-gupta requested a review from a team as a code owner June 2, 2025 23:31
@meg-gupta
Copy link
Contributor Author

@swift-ci test

@@ -231,6 +231,24 @@ class LifetimeDependenceInfo {
|| !conditionallyAddressableParamIndices
|| conditionallyAddressableParamIndices->isDisjointWith(
addressableParamIndices)));
#ifndef NDEBUG
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead, use if (CONDITIONAL_ASSERT_enabled())

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@meg-gupta meg-gupta force-pushed the fixdeserializationcp branch from a5ce5b7 to 637f8ef Compare June 3, 2025 00:36
@meg-gupta
Copy link
Contributor Author

@swift-ci test

@meg-gupta
Copy link
Contributor Author

@swift-ci test windows platform

1 similar comment
@meg-gupta
Copy link
Contributor Author

@swift-ci test windows platform

@meg-gupta meg-gupta enabled auto-merge June 3, 2025 12:49
@meg-gupta meg-gupta merged commit 20ff6af into swiftlang:release/6.2 Jun 3, 2025
5 checks passed
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.

3 participants