Skip to content

[Concurrency] Use overload resolution to stub voucher_needs_adopt. #39195

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
Sep 7, 2021

Conversation

mikeash
Copy link
Contributor

@mikeash mikeash commented Sep 7, 2021

Using has_include to conditionalize the stubbing of voucher_needs_adopt doesn't work when the SDK provides an older header that doesn't declare the function. Instead, always provide a stub, but use overload resolution to prefer the SDK's declaration. Declare the stub as taking void *. When calling it with voucher_t, the implicit conversion is allowed, but causes the overload to be disfavored when the SDK's declaration takes voucher_t.

rdar://82797720

@mikeash mikeash requested review from tbkka and al45tair September 7, 2021 15:09
@mikeash
Copy link
Contributor Author

mikeash commented Sep 7, 2021

@swift-ci please smoke test

1 similar comment
@mikeash
Copy link
Contributor Author

mikeash commented Sep 7, 2021

@swift-ci please smoke test

Using has_include to conditionalize the stubbing of voucher_needs_adopt doesn't work when the SDK provides an older header that doesn't declare the function. Instead, always provide a stub, but use overload resolution to prefer the SDK's declaration. Declare the stub as taking `void *`. When calling it with `voucher_t`, the implicit conversion is allowed, but causes the overload to be disfavored when the SDK's declaration takes `voucher_t`.

rdar://82797720
@mikeash mikeash force-pushed the voucher-needs-adopt-overload branch from 8bcb713 to c216d91 Compare September 7, 2021 16:26
@mikeash
Copy link
Contributor Author

mikeash commented Sep 7, 2021

@swift-ci please smoke test

Copy link
Member

@DougGregor DougGregor left a comment

Choose a reason for hiding this comment

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

I approve of this abuse of the C++ overloading mechanism

@mikeash mikeash merged commit 54a7577 into swiftlang:main Sep 7, 2021
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