diff --git a/compiler/testData/codegen/box/cinterop/objc/kt34467.kt b/compiler/testData/codegen/box/cinterop/objc/kt34467.kt new file mode 100644 index 00000000000..4a4b7541b08 --- /dev/null +++ b/compiler/testData/codegen/box/cinterop/objc/kt34467.kt @@ -0,0 +1,35 @@ +// TARGET_BACKEND: NATIVE +// DISABLE_NATIVE: isAppleTarget=false + +// FREE_CINTEROP_ARGS: -compiler-option -fmodule-map-file=$generatedSourcesDir/cinterop/module_library.modulemap +// FREE_CINTEROP_ARGS: -compiler-option -I$generatedSourcesDir/cinterop +// MODULE: cinterop +// FILE: module_library.def +language = Objective-C +modules = module_library + +// FILE: module_library.modulemap +module module_library { + umbrella header "module_library_umbrella.h" + + export * + module * { export * } +} + +// FILE: module_library_umbrella.h +#import + +// FILE: foo.h +#define ANSWER 42 + +// MODULE: main(cinterop) +// FILE: main.kt +@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class) +import module_library.* + +fun box(): String { + val answer = ANSWER + if (answer != 42) + return "FAIL: $answer" + return "OK" +} diff --git a/kotlin-native/backend.native/tests/build.gradle b/kotlin-native/backend.native/tests/build.gradle index e3c4f1497b2..b53a031a331 100644 --- a/kotlin-native/backend.native/tests/build.gradle +++ b/kotlin-native/backend.native/tests/build.gradle @@ -1160,12 +1160,6 @@ if (PlatformInfo.isAppleTarget(project)) { it.extraOpts '-Xforeign-exception-mode', "objc-wrap" } - createInterop("objcKt34467") { - it.defFile 'interop/objc/kt34467/module_library.def' - def moduleMap = file("interop/objc/kt34467/module_library.modulemap").absolutePath - def includePath = file("interop/objc/kt34467").absolutePath - it.compilerOpts "-fmodule-map-file=$moduleMap", "-I$includePath" - } createInterop("objcGh3343") { it.defFile 'framework/gh3343/objclib.def' it.headers "$projectDir/framework/gh3343/objclib.h" @@ -1631,12 +1625,6 @@ if (PlatformInfo.isAppleTarget(project)) { } } - interopTest("interop_objc_kt34467") { - source = "interop/objc/kt34467/foo.kt" - interop = 'objcKt34467' - useGoldenData = true - } - interopTest("interop_objc_illegal_sharing_with_weak") { source = "interop/objc/illegal_sharing_with_weak/main.kt" interop = 'objc_illegal_sharing_with_weak' diff --git a/kotlin-native/backend.native/tests/interop/objc/kt34467/foo.h b/kotlin-native/backend.native/tests/interop/objc/kt34467/foo.h deleted file mode 100644 index 6f57fb0a9b4..00000000000 --- a/kotlin-native/backend.native/tests/interop/objc/kt34467/foo.h +++ /dev/null @@ -1 +0,0 @@ -#define ANSWER 42 \ No newline at end of file diff --git a/kotlin-native/backend.native/tests/interop/objc/kt34467/foo.kt b/kotlin-native/backend.native/tests/interop/objc/kt34467/foo.kt deleted file mode 100644 index 34dfbdfc5ce..00000000000 --- a/kotlin-native/backend.native/tests/interop/objc/kt34467/foo.kt +++ /dev/null @@ -1,6 +0,0 @@ -import module_library.* - -fun main() { - println("OK") - println(ANSWER) -} \ No newline at end of file diff --git a/kotlin-native/backend.native/tests/interop/objc/kt34467/foo.out b/kotlin-native/backend.native/tests/interop/objc/kt34467/foo.out deleted file mode 100644 index eb3d67546b0..00000000000 --- a/kotlin-native/backend.native/tests/interop/objc/kt34467/foo.out +++ /dev/null @@ -1,2 +0,0 @@ -OK -42 diff --git a/kotlin-native/backend.native/tests/interop/objc/kt34467/module_library.def b/kotlin-native/backend.native/tests/interop/objc/kt34467/module_library.def deleted file mode 100644 index 3038e078a4f..00000000000 --- a/kotlin-native/backend.native/tests/interop/objc/kt34467/module_library.def +++ /dev/null @@ -1,2 +0,0 @@ -language = Objective-C -modules = module_library \ No newline at end of file diff --git a/kotlin-native/backend.native/tests/interop/objc/kt34467/module_library.modulemap b/kotlin-native/backend.native/tests/interop/objc/kt34467/module_library.modulemap deleted file mode 100644 index b9fbc34f98d..00000000000 --- a/kotlin-native/backend.native/tests/interop/objc/kt34467/module_library.modulemap +++ /dev/null @@ -1,6 +0,0 @@ -module module_library { - umbrella header "module_library_umbrella.h" - - export * - module * { export * } -} diff --git a/kotlin-native/backend.native/tests/interop/objc/kt34467/module_library_umbrella.h b/kotlin-native/backend.native/tests/interop/objc/kt34467/module_library_umbrella.h deleted file mode 100644 index e3262d6e539..00000000000 --- a/kotlin-native/backend.native/tests/interop/objc/kt34467/module_library_umbrella.h +++ /dev/null @@ -1 +0,0 @@ -#import 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 366dedba6a1..ecbf4b5a805 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 @@ -5068,6 +5068,12 @@ public class FirNativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTe KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/objc"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); } + @Test + @TestMetadata("kt34467.kt") + public void testKt34467() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/objc/kt34467.kt"); + } + @Test @TestMetadata("kt53151.kt") public void testKt53151() throws Exception { 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 b6a78b8ebbc..d0afabe23c5 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 @@ -5184,6 +5184,12 @@ public class FirNativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenB KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/objc"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); } + @Test + @TestMetadata("kt34467.kt") + public void testKt34467() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/objc/kt34467.kt"); + } + @Test @TestMetadata("kt53151.kt") public void testKt53151() throws Exception { 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 6054498b537..de117b43d50 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 @@ -4952,6 +4952,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/objc"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); } + @Test + @TestMetadata("kt34467.kt") + public void testKt34467() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/objc/kt34467.kt"); + } + @Test @TestMetadata("kt53151.kt") public void testKt53151() throws Exception { 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 2898bb3b4cf..ec7e379baa2 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 @@ -5069,6 +5069,12 @@ public class NativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenBoxT KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/cinterop/objc"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); } + @Test + @TestMetadata("kt34467.kt") + public void testKt34467() throws Exception { + runTest("compiler/testData/codegen/box/cinterop/objc/kt34467.kt"); + } + @Test @TestMetadata("kt53151.kt") public void testKt53151() throws Exception {