[K/N] Make a reproducer test for KT-55938
^KT-55938
diff --git a/kotlin-native/backend.native/tests/build.gradle b/kotlin-native/backend.native/tests/build.gradle
index f799c6c..e1f56ab 100644
--- a/kotlin-native/backend.native/tests/build.gradle
+++ b/kotlin-native/backend.native/tests/build.gradle
@@ -4443,6 +4443,10 @@
it.defFile 'interop/objc/kt53151/objclib.def'
it.compilerOpts "-F$projectDir/interop/objc/kt53151/testFramework"
}
+ createInterop("objc_kt55938") {
+ it.defFile 'interop/objc/kt55938/objclib.def'
+ it.headers "$projectDir/interop/objc/kt55938/objclib.h"
+ }
createInterop("kt49034_struct") {
it.defFile 'interop/objc/kt49034/struct/kt49034.def'
@@ -5166,6 +5170,7 @@
UtilsKt.codesign(project, "$buildDir/libobjc_kt42172.dylib")
}
}
+
}
interopTest("interop_objc_kt48816_without_lazy_ir_for_caches") {
@@ -5197,6 +5202,34 @@
interop = "objc_kt53151"
}
+ interopTest("interop_objc_kt55938") {
+ source = "interop/objc/kt55938/main.kt"
+ lib = "interop/objc/kt55938/lib.kt"
+ interop = "objc_kt55938"
+ useGoldenData = true
+ enabled = cacheTesting != null
+ flags = [
+ "-Xauto-cache-from=$testOutputRoot/local/objc_kt55938",
+ "-Xauto-cache-from=$testOutputRoot/local/interop_objc_kt55938",
+ "-Xauto-cache-dir=$testOutputRoot/local/interop_objc_kt55938/cache",
+ "-Werror" // to forbid retry with auto-cache disabled
+ ]
+
+ doBeforeBuild {
+ mkdir(buildDir)
+ def cacheDir = new File("-Xauto-cache-dir=$testOutputRoot/local/interop_objc_kt55938/cache")
+ cacheDir.deleteDir()
+ project.extensions.execClang.execClangForCompilerTests(project.target) {
+ args "$projectDir/interop/objc/kt55938/objclib.m"
+ args "-lobjc", '-fobjc-arc'
+ args '-fPIC', '-shared', '-o', "$buildDir/libobjc_kt55938.dylib"
+ }
+ if (UtilsKt.isSimulatorTarget(project, project.target)) {
+ UtilsKt.codesign(project, "$buildDir/libobjc_kt55938.dylib")
+ }
+ }
+ }
+
standaloneTest("objc_arc_contract") {
doBeforeBuild {
mkdir(buildDir)
diff --git a/kotlin-native/backend.native/tests/interop/objc/kt55938/lib.kt b/kotlin-native/backend.native/tests/interop/objc/kt55938/lib.kt
new file mode 100644
index 0000000..7cf158e
--- /dev/null
+++ b/kotlin-native/backend.native/tests/interop/objc/kt55938/lib.kt
@@ -0,0 +1,10 @@
+/*
+ * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
+ * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
+ */
+
+package kt55938lib
+
+import objclib.*
+
+inline fun foo() = ObjCClass.foo()
diff --git a/kotlin-native/backend.native/tests/interop/objc/kt55938/main.kt b/kotlin-native/backend.native/tests/interop/objc/kt55938/main.kt
new file mode 100644
index 0000000..d8c0c7b
--- /dev/null
+++ b/kotlin-native/backend.native/tests/interop/objc/kt55938/main.kt
@@ -0,0 +1,10 @@
+/*
+ * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
+ * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
+ */
+
+import kt55938lib.*
+
+fun main() {
+ print("foo() call result is ${foo()}")
+}
\ No newline at end of file
diff --git a/kotlin-native/backend.native/tests/interop/objc/kt55938/main.out b/kotlin-native/backend.native/tests/interop/objc/kt55938/main.out
new file mode 100644
index 0000000..7b82c15
--- /dev/null
+++ b/kotlin-native/backend.native/tests/interop/objc/kt55938/main.out
@@ -0,0 +1 @@
+foo() call result is 42
\ No newline at end of file
diff --git a/kotlin-native/backend.native/tests/interop/objc/kt55938/objclib.def b/kotlin-native/backend.native/tests/interop/objc/kt55938/objclib.def
new file mode 100644
index 0000000..de366f8
--- /dev/null
+++ b/kotlin-native/backend.native/tests/interop/objc/kt55938/objclib.def
@@ -0,0 +1,3 @@
+language = Objective-C
+headerFilter = **/objclib.h
+linkerOpts = -lobjc_kt55938
diff --git a/kotlin-native/backend.native/tests/interop/objc/kt55938/objclib.h b/kotlin-native/backend.native/tests/interop/objc/kt55938/objclib.h
new file mode 100644
index 0000000..5103e88
--- /dev/null
+++ b/kotlin-native/backend.native/tests/interop/objc/kt55938/objclib.h
@@ -0,0 +1,5 @@
+#import <Foundation/Foundation.h>
+
+@interface ObjCClass : NSObject
++ (int)foo;
+@end
\ No newline at end of file
diff --git a/kotlin-native/backend.native/tests/interop/objc/kt55938/objclib.m b/kotlin-native/backend.native/tests/interop/objc/kt55938/objclib.m
new file mode 100644
index 0000000..a0f318f
--- /dev/null
+++ b/kotlin-native/backend.native/tests/interop/objc/kt55938/objclib.m
@@ -0,0 +1,11 @@
+#include "objclib.h"
+
+
+@implementation ObjCClass {
+}
+
++ (int)foo {
+ return 42;
+}
+
+@end
\ No newline at end of file