KT-64931: add convertion of kotlin top-lvl functions into swift static functions

Merge-request: KT-MR-13878
Merged-by: Artem Olkov <artem.olkov@jetbrains.com>
This commit is contained in:
Artem Olkov
2024-01-17 20:30:04 +00:00
committed by Space Team
parent 01824a336c
commit 37a8723a79
24 changed files with 133 additions and 25 deletions
@@ -164,7 +164,7 @@ class SwiftExportExtension(
}
override fun visitFunction(function: SirFunction) {
val fqName = (function.origin as? SirKotlinOrigin.Function)?.fqName
val fqName = (function.origin as? SirKotlinOrigin.Function)?.path
?: return
val fqNameForBridge = if (fqName.count() == 1) {
listOf("__root__", fqName.first()) // todo: should be changed with correct mangling KT-64970
+2
View File
@@ -5,3 +5,5 @@ int32_t namespace1_main_foobar(int32_t param);
int32_t namespace1_foo();
int32_t namespace2_bar();
int32_t __root___foo();
+6
View File
@@ -17,3 +17,9 @@ public fun namespace2_bar(): Int {
val result = namespace2.bar()
return result
}
@ExportedBridge("__root___foo")
public fun __root___foo(): Int {
val result = foo()
return result
}
+7 -3
View File
@@ -1,18 +1,22 @@
enum namespace1 {
enum main {
public func foobar(
public static func foobar(
param: Swift.Int32
) -> Swift.Int32 {
return namespace1_main_foobar(param)
}
}
public func foo() -> Swift.Int32 {
public static func foo() -> Swift.Int32 {
return namespace1_foo()
}
}
enum namespace2 {
public func bar() -> Swift.Int32 {
public static func bar() -> Swift.Int32 {
return namespace2_bar()
}
}
public func foo() -> Swift.Int32 {
return __root___foo()
}
+3
View File
@@ -1,5 +1,8 @@
// WITH_STDLIB
// FILE: no_package.kt
fun foo(): Int = 123
// FILE: foo.kt
package namespace1
fun foo(): Int = 123