Skip to content

[6.0][CSBindings] Optional object type variable should be connected to the optional #73983

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
May 30, 2024

Conversation

xedin
Copy link
Contributor

@xedin xedin commented May 29, 2024

Cherry-pick of #73960


  • Explanation:

    Fixes a recent regression in for-in lookup type-checking.

    If both sides of an OptionalObject constraint are un-inferred, their
    binding sets need to correctly reflect adjacency - a type variable
    that represents optional would get "object" as an adjacency through
    its potential binding (the binding is - "object" wrapped in a single
    level of optional) and "object" type variable needs to get its parent
    optional type variable added to its adjacency list explicitly.

    Without this it would be possible to prematurely pick "object" before
    its parent optional type variable.

  • Scope: One known situation where this comes up is for-in loop where the pattern has an explicit contextual type.

  • Main Branch PRs: [CSBindings] Optional object type variable should be connected to the optional #73960

  • Resolves: (type checker) regression on main in subtyping rules for tuple labels #73207

  • Resolves: rdar://126960579

  • Risk: Low

  • Reviewed By: @hborla

  • Testing: Added new test-cases to the test suite

xedin added 2 commits May 29, 2024 10:14
… optional

If both sides of an `OptionalObject` constraint are un-inferred, their
binding sets need to correctly reflect adjacency - a type variable
that represents optional would get "object" as an adjacency through
its potential binding (the binding is - "object" wrapped in a single
level of optional) and "object" type variable needs to get its parent
optional type variable added to its adjacency list explicitly.
Without this it would be possible to prematurely pick "object" before
its parent optional type variable.

Resolves: swiftlang#73207
Resolves: rdar://126960579
(cherry picked from commit d7a0628)
If the contextual type propagated into the optional chain mismatches with
the inner type formed from its member references and that inner type
is a result of some fix, let's consider that un-salvageable and avoid
producing additional "ignore contextual type" fixes which only lead
to subpar solutions.

(cherry picked from commit 243cc16)
@xedin xedin requested a review from hborla May 29, 2024 17:17
@xedin xedin requested a review from a team as a code owner May 29, 2024 17:17
@xedin xedin added swift 6.0 🍒 release cherry pick Flag: Release branch cherry picks labels May 29, 2024
@xedin
Copy link
Contributor Author

xedin commented May 29, 2024

@swift-ci please test

@hborla hborla merged commit 9746fe7 into swiftlang:release/6.0 May 30, 2024
5 checks passed
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 swift 6.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants