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
Explanation: C++ foreign reference types have custom reference counting mechanisms, so they cannot conform to
AnyObject
. Currently Swift's type system treats C++ FRTs asAnyObject
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 toAnyObject
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-hunOriginal PR: https://github.com/swiftlang/swift/pull/74185