Skip to content

Conversation

@egorzhdan
Copy link
Contributor

@egorzhdan egorzhdan commented Sep 26, 2024

Explanation: 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.
Scope: Makes sure the special typechecker rule for FRTs is applied when Obj-C interop is disabled.
Risk: Low, only takes effect when Obj-C interop is disabled, and FRTs are used.
Testing: Enabled an existing compiler test on Linux and Windows.
Issue: rdar://136664617
Reviewer: @Xazax-hun

Original PR: #74185

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
(cherry picked from commit 82c076c)
@egorzhdan egorzhdan added the c++ interop Feature: Interoperability with C++ label Sep 26, 2024
@egorzhdan
Copy link
Contributor Author

@swift-ci please test

@egorzhdan egorzhdan marked this pull request as ready for review September 26, 2024 12:06
@egorzhdan egorzhdan requested a review from a team as a code owner September 26, 2024 12:06
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!

@egorzhdan egorzhdan merged commit 8f3822e into release/6.0 Sep 26, 2024
@egorzhdan egorzhdan deleted the egorzhdan/6.0-frt-test-nonobjc branch September 26, 2024 17:34
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.

4 participants