From f645a10aa0026e7392663b5477cff964dbdd2162 Mon Sep 17 00:00:00 2001 From: SvyatoslavScherbina Date: Wed, 8 Apr 2020 15:21:49 +0300 Subject: [PATCH] Fix spurious failure of interop_objc_smoke:testObjCWeakRef --- backend.native/tests/interop/objc/smoke.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/backend.native/tests/interop/objc/smoke.kt b/backend.native/tests/interop/objc/smoke.kt index f5e08e0a634..6110415a85e 100644 --- a/backend.native/tests/interop/objc/smoke.kt +++ b/backend.native/tests/interop/objc/smoke.kt @@ -596,7 +596,14 @@ fun testObjCWeakRef0(deallocListener: DeallocListener) = withWorker { obj.freeze() runInWorker { - assertFalse(deallocListener.deallocExecutorIsNil()) + // [deallocListener.deallocExecutorIsNil()] calls deallocExecutor getter, which retains [obj] and either + // puts it to autoreleasepool or releases it immediately (Obj-C ARC optimization). + // Wrap the call to autoreleasepool to ensure [obj] will be released: + autoreleasepool { + assertFalse(deallocListener.deallocExecutorIsNil()) + } + // Process release of Kotlin reference to [obj] in any case: + kotlin.native.internal.GC.collect() } }