Skip to content

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 hyp and zoecarver 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

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.

3 participants