Don't add name mangling to top-level internal functions

Turns out kotlinc only adds this sort of name mangling to class member functions
This commit is contained in:
Chris Smowton
2022-12-02 17:38:16 +00:00
parent edfcc0cd6d
commit ff4baf096f
4 changed files with 10 additions and 1 deletions

View File

@@ -821,7 +821,7 @@ open class KotlinUsesExtractor(
OperatorNameConventions.INVOKE.asString())
fun getSuffixIfInternal() =
if (f.visibility == DescriptorVisibilities.INTERNAL && f !is IrConstructor) {
if (f.visibility == DescriptorVisibilities.INTERNAL && f !is IrConstructor && !(f.parent is IrFile || isExternalFileClassMember(f))) {
"\$" + getJvmModuleName(f)
} else {
""

View File

@@ -1,5 +1,6 @@
public class Java {
void javaFun() {
new Kotlin().kotlinFun$main();
KotlinKt.topLevelKotlinFun();
}
}

View File

@@ -3,3 +3,4 @@ public class Kotlin {
}
}
internal fun topLevelKotlinFun() { }

View File

@@ -1,9 +1,16 @@
isPublic
isInternal
| Kotlin.kt:2:11:3:2 | kotlinFun$main |
| Kotlin.kt:6:10:6:36 | topLevelKotlinFun |
modifiers_methods
| file://:0:0:0:0 | final | Kotlin.kt:2:11:3:2 | kotlinFun$main |
| file://:0:0:0:0 | final | Kotlin.kt:6:10:6:36 | topLevelKotlinFun |
| file://:0:0:0:0 | internal | Kotlin.kt:2:11:3:2 | kotlinFun$main |
| file://:0:0:0:0 | internal | Kotlin.kt:6:10:6:36 | topLevelKotlinFun |
| file://:0:0:0:0 | static | Kotlin.kt:6:10:6:36 | topLevelKotlinFun |
#select
| Kotlin.kt:2:11:3:2 | kotlinFun$main | final |
| Kotlin.kt:2:11:3:2 | kotlinFun$main | internal |
| Kotlin.kt:6:10:6:36 | topLevelKotlinFun | final |
| Kotlin.kt:6:10:6:36 | topLevelKotlinFun | internal |
| Kotlin.kt:6:10:6:36 | topLevelKotlinFun | static |