Skip to content

[cxx-interop] C++ reference types are not AnyObjects #74185

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 26, 2024

Conversation

egorzhdan
Copy link
Contributor

@egorzhdan egorzhdan commented Jun 6, 2024

C++ foreign reference types have custom reference counting mechanisms, so they cannot conform to AnyObject.

Currently Swift's type system treats C++ FRTs as AnyObjects on non-Darwin platforms, which is incorrect. This change makes sure the behavior is consistent with Darwin platform, i.e. a cast of C++ FRT to AnyObject is rejected by the typechecker.

rdar://136664617

@egorzhdan egorzhdan added the c++ interop Feature: Interoperability with C++ label Jun 6, 2024
@egorzhdan egorzhdan requested review from zoecarver and hyp as code owners June 6, 2024 18:56
@egorzhdan
Copy link
Contributor Author

@swift-ci please test

@egorzhdan egorzhdan force-pushed the egorzhdan/frt-test-nonobjc branch from 39f1822 to 4da9a87 Compare June 7, 2024 12:59
@egorzhdan
Copy link
Contributor Author

@swift-ci please test

@egorzhdan egorzhdan enabled auto-merge June 7, 2024 13:00
@egorzhdan egorzhdan force-pushed the egorzhdan/frt-test-nonobjc branch from 4da9a87 to 29992d2 Compare June 7, 2024 19:34
@egorzhdan
Copy link
Contributor Author

@swift-ci please test

1 similar comment
@egorzhdan
Copy link
Contributor Author

@swift-ci please test

@egorzhdan egorzhdan force-pushed the egorzhdan/frt-test-nonobjc branch from 29992d2 to 84ecffc Compare September 25, 2024 11:47
@egorzhdan egorzhdan changed the title [cxx-interop] Enable a test for reference types on non-Darwin [cxx-interop] C++ reference types are not AnyObjects Sep 25, 2024
@egorzhdan egorzhdan requested a review from Xazax-hun September 25, 2024 11:47
@egorzhdan
Copy link
Contributor Author

@swift-ci please test

@egorzhdan egorzhdan disabled auto-merge September 25, 2024 11:50
Copy link
Contributor

@Xazax-hun Xazax-hun left a comment

Choose a reason for hiding this comment

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

LGTM!

C++ foreign reference types have custom reference counting mechanisms, so they cannot conform to `AnyObject`.

Currently Swift's type system treats C++ FRTs as `AnyObject`s on non-Darwin platforms, which is incorrect. This change makes sure the behavior is consistent with Darwin platform, i.e. a cast of C++ FRT to `AnyObject` is rejected by the typechecker.

rdar://136664617
@egorzhdan egorzhdan force-pushed the egorzhdan/frt-test-nonobjc branch from 84ecffc to 82c076c Compare September 25, 2024 14:15
@egorzhdan
Copy link
Contributor Author

@swift-ci please test

@egorzhdan egorzhdan merged commit c126bab into main Sep 26, 2024
5 checks passed
@egorzhdan egorzhdan deleted the egorzhdan/frt-test-nonobjc branch September 26, 2024 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ interop Feature: Interoperability with C++
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants