KT-64932: add support for no-package top level functions
Merge-request: KT-MR-13879 Merged-by: Artem Olkov <artem.olkov@jetbrains.com>
This commit is contained in:
+6
-1
@@ -166,9 +166,14 @@ class SwiftExportExtension(
|
|||||||
override fun visitFunction(function: SirFunction) {
|
override fun visitFunction(function: SirFunction) {
|
||||||
val fqName = (function.origin as? SirKotlinOrigin.Function)?.fqName
|
val fqName = (function.origin as? SirKotlinOrigin.Function)?.fqName
|
||||||
?: return
|
?: return
|
||||||
|
val fqNameForBridge = if (fqName.count() == 1) {
|
||||||
|
listOf("__root__", fqName.first()) // todo: should be changed with correct mangling KT-64970
|
||||||
|
} else {
|
||||||
|
fqName
|
||||||
|
}
|
||||||
val bridgeRequest = BridgeRequest(
|
val bridgeRequest = BridgeRequest(
|
||||||
function,
|
function,
|
||||||
fqName.joinToString("_"),
|
fqNameForBridge.joinToString("_"),
|
||||||
fqName
|
fqName
|
||||||
)
|
)
|
||||||
requests += bridgeRequest
|
requests += bridgeRequest
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
int32_t __root___meaningOfLife();
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import kotlin.native.internal.ExportedBridge
|
||||||
|
|
||||||
|
@ExportedBridge("__root___meaningOfLife")
|
||||||
|
public fun __root___meaningOfLife(): Int {
|
||||||
|
val result = meaningOfLife()
|
||||||
|
return result
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
public func meaningOfLife() -> Swift.Int32 {
|
||||||
|
return __root___meaningOfLife()
|
||||||
|
}
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
fun meaningOfLife(): Int = 420
|
||||||
+6
@@ -25,6 +25,12 @@ public class SwiftExportCompilerPluginTest extends AbstractSwiftExportContextTes
|
|||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/swift-export/testData"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile(".*\\.golden\\.kt$"), TargetBackend.JVM, false);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/swift-export/testData"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile(".*\\.golden\\.kt$"), TargetBackend.JVM, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("no_package.kt")
|
||||||
|
public void testNo_package() throws Exception {
|
||||||
|
runTest("plugins/swift-export/testData/no_package.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("simple.kt")
|
@TestMetadata("simple.kt")
|
||||||
public void testSimple() throws Exception {
|
public void testSimple() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user