Skip to content

[5.5][Sema] Use different solution vectors for ComponentSteps created by DependentComponentSplitterStep #38061

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
Jun 24, 2021

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Jun 23, 2021

  • Explanation:
    Currently all ComponentSteps created by DependentComponentSplitterStep share the same Solutions vector. Because of this, the ComponentSteps might modify solutions created by previous ComponentSteps. Use different Solutions vectors for each ComponentStep to avoid sharing information between the ComponentSteps.
    For example, in the added test case the qadding(bar:) overload gets added to Solutions, it’s score gets reduced by its ComponentStep original score, then the qadding(foo:) overload gets added to Solutions and both solutions have their score decreased by the OriginalScore of qadding(foo:)’s ComponentStep, causing qadding(bar:)’s score to underflow.
  • Scope: Result builder bodies where dependent expressions produce multiple solutions which need to be reconciled
  • Risk: Low
  • Testing: Added regression test
  • Issue: rdar://78780840
  • Reviewer: @xedin (Pavel Yaskevich) on original PR [Sema] Use different solution vectors for ComponentSteps created by DependentComponentSplitterStep #37964

… `DependentComponentSplitterStep`

Currently all `ComponentSteps` created by `DependentComponentSplitterStep` share the same `Solutions` vector. Because of this, the `ComponentStep`s might modify solutions created by previous `ComponentStep`s. Use different `Solutions` vectors for each `ComponentStep` to avoid sharing information between the `ComponentStep`s.

The concrete manifestation in the added test case is that the `Bar` overload gets added to `Solutions`, it’s score gets reduced by its `ComponentStep` original score, then the `Foo` overload gets added to `Solutions` and both solutions have their score decreased by the `OriginalScore` of `Foo`’s `ComponentStep`, causing `Bar`’s score to underflow.

Fixes rdar://78780840 [SR-14692]
@ahoppen ahoppen added the r5.5 label Jun 23, 2021
@ahoppen ahoppen requested a review from a team as a code owner June 23, 2021 17:53
@ahoppen
Copy link
Member Author

ahoppen commented Jun 23, 2021

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 7021282

@ahoppen
Copy link
Member Author

ahoppen commented Jun 24, 2021

@swift-ci Please test Linux

@ahoppen
Copy link
Member Author

ahoppen commented Jun 24, 2021

@swift-ci Please test Windows

@ahoppen
Copy link
Member Author

ahoppen commented Jun 24, 2021

@swift-ci Please nominate

@akyrtzi akyrtzi merged commit 45699ce into swiftlang:release/5.5 Jun 24, 2021
@ahoppen ahoppen deleted the pr-5.5/solutions-scoring branch June 25, 2021 06:38
@AnthonyLatsis AnthonyLatsis added 🍒 release cherry pick Flag: Release branch cherry picks swift 5.5 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 swift 5.5
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants