From 171a7eb98c100f40500b5614713730064a804611 Mon Sep 17 00:00:00 2001 From: Svyatoslav Scherbina Date: Fri, 10 Apr 2020 12:53:25 +0300 Subject: [PATCH] Fix testObjCWeakRef on watchos_x86 etc. --- backend.native/tests/interop/objc/tests/objcWeakRefs.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/backend.native/tests/interop/objc/tests/objcWeakRefs.kt b/backend.native/tests/interop/objc/tests/objcWeakRefs.kt index 26f3beafffe..64428150f65 100644 --- a/backend.native/tests/interop/objc/tests/objcWeakRefs.kt +++ b/backend.native/tests/interop/objc/tests/objcWeakRefs.kt @@ -7,7 +7,12 @@ import objcTests.* val deallocListener = DeallocListener() assertFalse(deallocListener.deallocated) - testObjCWeakRef0(deallocListener) + // [deallocListener.deallocExecutorIsNil()] calls deallocExecutor getter, which retains the result and either + // puts it to autoreleasepool or releases it immediately (Obj-C ARC optimization). It seems to depend on the platform. + // Wrap the call to autoreleasepool to ensure the object will be released: + autoreleasepool { + testObjCWeakRef0(deallocListener) + } kotlin.native.internal.GC.collect() assertTrue(deallocListener.deallocated)