diff --git a/native/objcexport-header-generator/test/org/jetbrains/kotlin/backend/konan/tests/ObjCExportHeaderGeneratorTest.kt b/native/objcexport-header-generator/test/org/jetbrains/kotlin/backend/konan/tests/ObjCExportHeaderGeneratorTest.kt index d0626bca40c..ccc71e3282c 100644 --- a/native/objcexport-header-generator/test/org/jetbrains/kotlin/backend/konan/tests/ObjCExportHeaderGeneratorTest.kt +++ b/native/objcexport-header-generator/test/org/jetbrains/kotlin/backend/konan/tests/ObjCExportHeaderGeneratorTest.kt @@ -167,6 +167,11 @@ class ObjCExportHeaderGeneratorTest(val generator: HeaderGenerator) { doTest(headersTestDataDir.resolve("classWithUnresolvedSuperTypeGenerics")) } + @Test + fun `test - topLevelFunctionWithNumberReturn`() { + doTest(headersTestDataDir.resolve("topLevelFunctionWithNumberReturn")) + } + private fun doTest(root: File, configuration: Configuration = Configuration()) { if (!root.isDirectory) fail("Expected ${root.absolutePath} to be directory") val generatedHeaders = generator.generateHeaders(root, configuration).toString() diff --git a/native/objcexport-header-generator/testData/headers/topLevelFunctionWithNumberReturn/!topLevelFunctionWithNumberReturn.h b/native/objcexport-header-generator/testData/headers/topLevelFunctionWithNumberReturn/!topLevelFunctionWithNumberReturn.h new file mode 100644 index 00000000000..7d953649884 --- /dev/null +++ b/native/objcexport-header-generator/testData/headers/topLevelFunctionWithNumberReturn/!topLevelFunctionWithNumberReturn.h @@ -0,0 +1,37 @@ +#import +#import +#import +#import +#import +#import +#import + +NS_ASSUME_NONNULL_BEGIN +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunknown-warning-option" +#pragma clang diagnostic ignored "-Wincompatible-property-type" +#pragma clang diagnostic ignored "-Wnullability" + +#pragma push_macro("_Nullable_result") +#if !__has_feature(nullability_nullable_result) +#undef _Nullable_result +#define _Nullable_result _Nullable +#endif + +__attribute__((objc_subclassing_restricted)) +@interface FooKt : Base ++ (int8_t)myByte __attribute__((swift_name("myByte()"))); ++ (double)myDouble __attribute__((swift_name("myDouble()"))); ++ (float)myFloat __attribute__((swift_name("myFloat()"))); ++ (int32_t)myInt __attribute__((swift_name("myInt()"))); ++ (int64_t)myLong __attribute__((swift_name("myLong()"))); ++ (int16_t)myShort __attribute__((swift_name("myShort()"))); ++ (uint8_t)myUByte __attribute__((swift_name("myUByte()"))); ++ (uint32_t)myUInt __attribute__((swift_name("myUInt()"))); ++ (uint64_t)myULong __attribute__((swift_name("myULong()"))); ++ (uint16_t)myUShort __attribute__((swift_name("myUShort()"))); +@end + +#pragma pop_macro("_Nullable_result") +#pragma clang diagnostic pop +NS_ASSUME_NONNULL_END diff --git a/native/objcexport-header-generator/testData/headers/topLevelFunctionWithNumberReturn/Foo.kt b/native/objcexport-header-generator/testData/headers/topLevelFunctionWithNumberReturn/Foo.kt new file mode 100644 index 00000000000..191f258a5f2 --- /dev/null +++ b/native/objcexport-header-generator/testData/headers/topLevelFunctionWithNumberReturn/Foo.kt @@ -0,0 +1,14 @@ +fun myByte(): Byte = error("stub") +fun myUByte(): UByte = error("stub") + +fun myShort(): Short = error("stub") +fun myUShort(): UShort = error("stub") + +fun myInt(): Int = error("stub") +fun myUInt(): UInt = error("stub") + +fun myLong(): Long = error("stub") +fun myULong(): ULong = error("stub") + +fun myFloat(): Float = error("stub") +fun myDouble(): Double = error("stub")