Skip to content

Sema: Fix two problems in checkReferencedGenericParams() analysis [5.9] #67939

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

Conversation

slavapestov
Copy link
Contributor

  • Description: We require that all generic parameters are referenced in a function signature, because otherwise there is no way to call a function if a generic parameter isn't fixed by at least one constraint generated by the solver at the call site. This logic was wrong for pack expansion types, so you could in fact declare a function that cannot be called.
  • Risk: Low. This might break source if someone accidentally shipped an API that cannot be called for this reason.
  • Tested: New test added.
  • Reviewed by: @hborla

- Don't walk into the count type of a PackExpansionType, because
  when matching two PackExpansionTypes, the solver only introduces
  a shape constraint between the count types, which does not fix it
  to a concrete type.

- Similarly, don't walk into type alias substitutions, because
  only the desugared type is considered by the constraint solver.

This is mildly source breaking, in that before we let you declare
generic functions that could not be called.
@slavapestov slavapestov requested a review from a team as a code owner August 15, 2023 16:44
@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@slavapestov slavapestov merged commit 898f4a9 into swiftlang:release/5.9 Aug 15, 2023
slavapestov added a commit that referenced this pull request Sep 20, 2023
…param-fix-5.9

Sema: Partial revert of #67939 [5.9]
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