Skip to content

[5.4][CSBindings] Adjust type variable viability condition #37097

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
May 18, 2021

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Apr 27, 2021

  • Explanation:

Fixes an issue where valid code might fail due to incorrect inference.

To be viable to be attempted next type variable should have
at least one of the following:

  • a direct binding (from relational constraint);
  • a default (from Defaultable constraint);
  • a literal protocol conformance with a default type
    described by LiteralConformsTo constraint;

Third condition was under-defined in 5.4 since it would consider
all protocol requirements, but that discounts the fact that
only literal conformances could be binding sources, which leads
to problems where type variables with incomplete set of bindings
could be picked to be attempted.

  • Scope: Expressions with ternary operator that has literals on both sides passed as an argument to a generic function with conformance requirements to literal protocol(s).

  • Resolves: rdar://78035555

  • Risk: Very Low

  • Reviewed By: @hborla

  • Testing: Regression tests added to the suite

Resolves: rdar://78035555

To be viable to be attempted next type variable should have
at least one of the following:

- a direct binding (from relational constraint);
- a default (from `Defaultable` constraint);
- a literal protocol conformance with a default type
  described by `LiteralConformsTo` constraint;

Third condition was under-defined in 5.4 since it would consider
_all_ protocol requirements, but that discounts the fact that
only literal conformances could be binding sources, which leads
to problems where type variables with incomplete set of bindings
could be picked to be attempted.

Resolves: rdar://77233864
@xedin xedin requested a review from a team as a code owner April 27, 2021 22:55
@xedin
Copy link
Contributor Author

xedin commented Apr 27, 2021

@swift-ci please test

@xedin xedin requested a review from hborla May 17, 2021 18:04
@xedin xedin changed the title [CSBindings] Adjust type variable viability condition [5.4][CSBindings] Adjust type variable viability condition May 17, 2021
@xedin xedin added the r5.4 label May 17, 2021
@tkremenek tkremenek merged commit 549ce67 into swiftlang:release/5.4 May 18, 2021
@AnthonyLatsis AnthonyLatsis added swift 5.4 🍒 release cherry pick Flag: Release branch cherry picks labels Jan 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants