diff --git a/compiler/testData/codegen/box/cinterop/objc/illegal_sharing_with_weak.kt b/compiler/testData/codegen/box/cinterop/objc/sharing_with_weak.kt similarity index 81% rename from compiler/testData/codegen/box/cinterop/objc/illegal_sharing_with_weak.kt rename to compiler/testData/codegen/box/cinterop/objc/sharing_with_weak.kt index e7c0c38088c..185c307545b 100644 --- a/compiler/testData/codegen/box/cinterop/objc/illegal_sharing_with_weak.kt +++ b/compiler/testData/codegen/box/cinterop/objc/sharing_with_weak.kt @@ -18,7 +18,7 @@ void setObject(NSObject* obj) { // Make sure this function persists, because the test expects to find this function in the stack trace. __attribute__((noinline)) -bool isObjectAliveShouldCrash() { +bool isObjectAlive() { return globalObject != nil; } @@ -33,12 +33,11 @@ import objclib.* val sb = StringBuilder() fun box(): String { - autoreleasepool { + val success = autoreleasepool { run() } // Experimental MM supports arbitrary object sharing. - assertEquals("Before\nAfter true\n", sb.toString()) - return "OK" + return if (success) "OK" else "FAIL" } private class NSObjectImpl : NSObject() { @@ -49,13 +48,11 @@ fun run() = withWorker { val obj = NSObjectImpl() setObject(obj) - sb.appendLine("Before") - val isAlive = try { + try { execute(TransferMode.SAFE, {}) { - isObjectAliveShouldCrash() + isObjectAlive() }.result } catch (e: Throwable) { false } - sb.appendLine("After $isAlive") } diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestGenerated.java index 4093b759af6..7b97f087e72 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestGenerated.java @@ -5074,12 +5074,6 @@ public class FirNativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTe runTest("compiler/testData/codegen/box/cinterop/objc/direct.kt"); } - @Test - @TestMetadata("illegal_sharing_with_weak.kt") - public void testIllegal_sharing_with_weak() throws Exception { - runTest("compiler/testData/codegen/box/cinterop/objc/illegal_sharing_with_weak.kt"); - } - @Test @TestMetadata("kt34467.kt") public void testKt34467() throws Exception { @@ -5109,6 +5103,12 @@ public class FirNativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTe public void testOverridabilityCondition() throws Exception { runTest("compiler/testData/codegen/box/cinterop/objc/overridabilityCondition.kt"); } + + @Test + @TestMetadata("sharing_with_weak.kt") + public void testSharing_with_weak() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/objc/sharing_with_weak.kt"); + } } @Nested diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestNoPLGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestNoPLGenerated.java index 946ab3b4613..7678d236869 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestNoPLGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestNoPLGenerated.java @@ -5190,12 +5190,6 @@ public class FirNativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenB runTest("compiler/testData/codegen/box/cinterop/objc/direct.kt"); } - @Test - @TestMetadata("illegal_sharing_with_weak.kt") - public void testIllegal_sharing_with_weak() throws Exception { - runTest("compiler/testData/codegen/box/cinterop/objc/illegal_sharing_with_weak.kt"); - } - @Test @TestMetadata("kt34467.kt") public void testKt34467() throws Exception { @@ -5225,6 +5219,12 @@ public class FirNativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenB public void testOverridabilityCondition() throws Exception { runTest("compiler/testData/codegen/box/cinterop/objc/overridabilityCondition.kt"); } + + @Test + @TestMetadata("sharing_with_weak.kt") + public void testSharing_with_weak() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/objc/sharing_with_weak.kt"); + } } @Nested diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenBoxTestGenerated.java index 778da98600d..90327a1bf35 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenBoxTestGenerated.java @@ -4958,12 +4958,6 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest runTest("compiler/testData/codegen/box/cinterop/objc/direct.kt"); } - @Test - @TestMetadata("illegal_sharing_with_weak.kt") - public void testIllegal_sharing_with_weak() throws Exception { - runTest("compiler/testData/codegen/box/cinterop/objc/illegal_sharing_with_weak.kt"); - } - @Test @TestMetadata("kt34467.kt") public void testKt34467() throws Exception { @@ -4993,6 +4987,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest public void testOverridabilityCondition() throws Exception { runTest("compiler/testData/codegen/box/cinterop/objc/overridabilityCondition.kt"); } + + @Test + @TestMetadata("sharing_with_weak.kt") + public void testSharing_with_weak() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/objc/sharing_with_weak.kt"); + } } @Nested diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenBoxTestNoPLGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenBoxTestNoPLGenerated.java index 8fc7152e50c..b2da7befa9a 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenBoxTestNoPLGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenBoxTestNoPLGenerated.java @@ -5075,12 +5075,6 @@ public class NativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenBoxT runTest("compiler/testData/codegen/box/cinterop/objc/direct.kt"); } - @Test - @TestMetadata("illegal_sharing_with_weak.kt") - public void testIllegal_sharing_with_weak() throws Exception { - runTest("compiler/testData/codegen/box/cinterop/objc/illegal_sharing_with_weak.kt"); - } - @Test @TestMetadata("kt34467.kt") public void testKt34467() throws Exception { @@ -5110,6 +5104,12 @@ public class NativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenBoxT public void testOverridabilityCondition() throws Exception { runTest("compiler/testData/codegen/box/cinterop/objc/overridabilityCondition.kt"); } + + @Test + @TestMetadata("sharing_with_weak.kt") + public void testSharing_with_weak() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/objc/sharing_with_weak.kt"); + } } @Nested