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> {
62
62
struct VirtualRetainRelease {
63
63
int value;
64
64
mutable int refCount = 1 ;
65
+ mutable bool calledBase = false ;
65
66
VirtualRetainRelease (int value) : value(value) {}
66
67
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 ; }
69
70
virtual ~VirtualRetainRelease () = default ;
70
71
} SWIFT_SHARED_REFERENCE(.doRetainVirtual, .doReleaseVirtual);
71
72
72
73
struct DerivedVirtualRetainRelease : VirtualRetainRelease {
73
74
DerivedVirtualRetainRelease (int value) : VirtualRetainRelease(value) {}
74
75
75
- mutable bool calledDerived = false ;
76
- void doRetainVirtual () const override { refCount++; calledDerived = true ; }
76
+ void doRetainVirtual () const override { refCount++; }
77
77
void doReleaseVirtual () const override { refCount--; }
78
78
};
79
79
Original file line number Diff line number Diff line change 1
1
// RUN: %target-run-simple-swift(-I %S/Inputs -cxx-interoperability-mode=upcoming-swift -I %swift_src_root/lib/ClangImporter/SwiftBridging -Xfrontend -disable-availability-checking)
2
2
3
+ // REQUIRES: executable_test
4
+
3
5
// Temporarily disable when running with an older runtime (rdar://128681137)
4
6
// UNSUPPORTED: use_os_stdlib
5
7
// UNSUPPORTED: back_deployment_runtime
@@ -61,7 +63,7 @@ LifetimeMethodsTestSuite.test("virtual retain/release") {
61
63
LifetimeMethodsTestSuite . test ( " overridden virtual retain/release " ) {
62
64
let a = DerivedVirtualRetainRelease ( 456 )
63
65
expectEqual ( a. value, 456 )
64
- expectTrue ( a. calledDerived )
66
+ expectFalse ( a. calledBase ) // in optimized builds, we might not call retain/release at all
65
67
expectTrue ( a. refCount > 0 )
66
68
expectTrue ( a. refCount < 10 ) // optimizations would affect the exact number
67
69
}
You can’t perform that action at this time.
0 commit comments