Skip to content

[CSSimplify] Don't propagate contextual parameter type if it's a pack… #64531

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
Mar 23, 2023

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Mar 22, 2023

… expansion

Pack expansion types are handled by matching logic, optimization that attempts
to propagate types into the body of the closure should consider them unsuitable
even if the pack expansion matches a single parameter.

@xedin xedin requested a review from hborla as a code owner March 22, 2023 07:38
// Cannot propagate pack expansion type from context,
// it has to be handled by type matching logic.
if (contextualTy->is<PackExpansionType>())
return false;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I understand everything correctly we could allow that by using getPatternType but I think in vast majority of cases (if not all) it would result in a type variable anyway which is not a suitable type too.

Copy link
Member

Choose a reason for hiding this comment

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

We would need to wait until the pattern type is fully substituted and flattened. The pattern type in this case will be substituted with PackType{String}, and the pack expansion will flatten the pack type into just String

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, I figured that it better to let it go through the matching logic than try to do anything fancy here.

… expansion

Pack expansion types are handled by matching logic, optimization
that attempts to propagate types into the body of the closure should
consider them unsuitable even if the pack expansion matches a single
parameter.
@xedin xedin force-pushed the pack-expansion-and-closure-params branch from d7ec5fe to b4937be Compare March 22, 2023 16:10
@xedin
Copy link
Contributor Author

xedin commented Mar 22, 2023

@swift-ci please test

@xedin
Copy link
Contributor Author

xedin commented Mar 22, 2023

@swift-ci please clean test macOS platform

@xedin
Copy link
Contributor Author

xedin commented Mar 22, 2023

@swift-ci please test macOS platform

Copy link
Member

@hborla hborla left a comment

Choose a reason for hiding this comment

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

Thank you!

@xedin xedin merged commit b01568a into swiftlang:main Mar 23, 2023
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.

2 participants