Skip to content

[CS] Restore a type variable for compatibility with rdar://85263844 #40224

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 2 commits into from
Nov 18, 2021

Conversation

hamishknight
Copy link
Contributor

@hamishknight hamishknight commented Nov 17, 2021

This bit of logic was removed in #39543. However it turns out that despite this type variable being otherwise disconnected from the constraint system, it's possible for it to affect how we type-check tuple matches in certain cases.

This is due to the fact that:

  • It can have a lower type variable ID than an opened generic parameter type, so becomes the representative when merged with it. And because it has a different locator, this can influence binding prioritization.
  • Tuple subtyping is broken, as it's currently a weaker relationship than conversion due to allowing labeling mismatches.

Therefore, temporarily restore this bit of logic for language versions < 6. In addition, start warning on cases where we currently permit tuple label mismatches in subtyping. If possible, we should try and fix tuple subtying in Swift 6 mode to not accept label mismatches, so that it's not more permissive than tuple conversion.

rdar://85263844

Despite being otherwise disconnected from the
constraint system, it's possible for it to affect
how we type-check tuple matches in certain cases.

This is due to the fact that:
- It can have a lower type variable ID than an
opened generic parameter type, so becomes the
representative when merged with it. And because it
has a different locator, this can influence
binding prioritization.
- Tuple subtyping is broken, as it's currently a
*weaker* relationship than conversion.

Therefore, temporarily restore this bit of logic
for language versions < 6. If possible, we should
try and fix tuple subtying in Swift 6 mode to not
accept label mismatches, so that it's not more
permissive than tuple conversion.

rdar://85263844
This is something that we'd like to fix to bring
in line with tuple conversion, so start warning on
cases where it occurs.
@hamishknight
Copy link
Contributor Author

@swift-ci please test

@hamishknight
Copy link
Contributor Author

@swift-ci please test source compatibility

@hamishknight hamishknight requested a review from xedin November 17, 2021 17:26
@hamishknight hamishknight merged commit 237338b into swiftlang:main Nov 18, 2021
@hamishknight hamishknight deleted the super-tuple-shuffle branch November 18, 2021 09:50
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