Skip to content

[5.7🍒] ABISafeConversionComponent should be a TranslationComponent #61080

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
Sep 14, 2022

Conversation

kavon
Copy link
Member

@kavon kavon commented Sep 13, 2022

Cherry-pick of #61029

Resolves rdar://99619834

• Explanation: Accessing and/or writing to @preconcurrency vars containing functions would crash the compiler or emit bogus code.
• Scope of Issue: Anyone accessing such a var from ObjC, which is a pretty broad category.
• Origination: Introduced in the initial implementation of @preconcurrency, partially fixed in #60521. This PR builds on that fix to completely resolve the problem.
• Risk: Low. This change is only reimplementing a coercion in a later stage of the compiler IR, it doesn't affect the typechecker.
• Pull Request URL: #61080
• Reviewed By: John McCall
• Automated Testing: Regression test is included

…er than physical

Also renaming it to be UncheckedConversionComponent since it's a better name.

As a physical component, we'd run into problems in assignment statements.
The problem was that if we had something like:

```
SomeOtherComponent          // first component
GetterSetterComponent
ABISafeConversionComponent  // last component
```

When emitting the assignment, we always drill down through all but
the last component by calling `project()` on each one. Then on the last
component, we'd do the actual setting operation. But GetterSetterComponent
cannot be projected when the access is for writing.

So, to work around this I decided to model it as a TranslationComponent, because
those are specifically designed to be handled during an assignment by popping those
off the end of the component sequence, untranslating the value we're about to assign
as we go, until we hit the GetterSetterComponent.

By "untranslating" we're effectively putting Sendable back onto the set's argument
prior to calling set, because the underlying property's type still has `@Sendable`
on it (e.g., it's accessors still have that on its argument type). When
"translating" we're effectively taking Sendable off after reading it.

I think actually works really well and makes much more sense now.

resolves rdar://99619834
@kavon
Copy link
Member Author

kavon commented Sep 13, 2022

@swift-ci please test

@kavon kavon marked this pull request as ready for review September 13, 2022 21:12
@kavon kavon requested a review from a team as a code owner September 13, 2022 21:12
Copy link
Contributor

@rjmccall rjmccall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks okay to me

@kavon
Copy link
Member Author

kavon commented Sep 14, 2022

@swift-ci please nominate

@DougGregor DougGregor merged commit 4058fbf into swiftlang:release/5.7 Sep 14, 2022
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.

3 participants