File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed
test/Interop/Cxx/foreign-reference Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -62,18 +62,18 @@ struct CRTPDerived : CRTPBase<CRTPDerived> {
6262struct VirtualRetainRelease {
6363 int value;
6464 mutable int refCount = 1 ;
65+ mutable bool calledBase = false ;
6566 VirtualRetainRelease (int value) : value(value) {}
6667
67- virtual void doRetainVirtual () const { refCount++; }
68- virtual void doReleaseVirtual () const { refCount--; }
68+ virtual void doRetainVirtual () const { refCount++; calledBase = true ; }
69+ virtual void doReleaseVirtual () const { refCount--; calledBase = true ; }
6970 virtual ~VirtualRetainRelease () = default ;
7071} SWIFT_SHARED_REFERENCE(.doRetainVirtual, .doReleaseVirtual);
7172
7273struct DerivedVirtualRetainRelease : VirtualRetainRelease {
7374 DerivedVirtualRetainRelease (int value) : VirtualRetainRelease(value) {}
7475
75- mutable bool calledDerived = false ;
76- void doRetainVirtual () const override { refCount++; calledDerived = true ; }
76+ void doRetainVirtual () const override { refCount++; }
7777 void doReleaseVirtual () const override { refCount--; }
7878};
7979
Original file line number Diff line number Diff line change 11// RUN: %target-run-simple-swift(-I %S/Inputs -cxx-interoperability-mode=upcoming-swift -I %swift_src_root/lib/ClangImporter/SwiftBridging -Xfrontend -disable-availability-checking)
22
3+ // REQUIRES: executable_test
4+
35// Temporarily disable when running with an older runtime (rdar://128681137)
46// UNSUPPORTED: use_os_stdlib
57// UNSUPPORTED: back_deployment_runtime
@@ -61,7 +63,7 @@ LifetimeMethodsTestSuite.test("virtual retain/release") {
6163LifetimeMethodsTestSuite . test ( " overridden virtual retain/release " ) {
6264 let a = DerivedVirtualRetainRelease ( 456 )
6365 expectEqual ( a. value, 456 )
64- expectTrue ( a. calledDerived )
66+ expectFalse ( a. calledBase ) // in optimized builds, we might not call retain/release at all
6567 expectTrue ( a. refCount > 0 )
6668 expectTrue ( a. refCount < 10 ) // optimizations would affect the exact number
6769}
You can’t perform that action at this time.
0 commit comments