Skip to content

Commit 8897f5b

Browse files
authored
Merge pull request github#11552 from smowton/smowton/fix/kotlin-toplevel-internal-names
Kotlin: Don't add name mangling to top-level internal functions
2 parents 5b31da4 + ff4baf0 commit 8897f5b

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

java/kotlin-extractor/src/main/kotlin/KotlinUsesExtractor.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ open class KotlinUsesExtractor(
821821
OperatorNameConventions.INVOKE.asString())
822822

823823
fun getSuffixIfInternal() =
824-
if (f.visibility == DescriptorVisibilities.INTERNAL && f !is IrConstructor) {
824+
if (f.visibility == DescriptorVisibilities.INTERNAL && f !is IrConstructor && !(f.parent is IrFile || isExternalFileClassMember(f))) {
825825
"\$" + getJvmModuleName(f)
826826
} else {
827827
""
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
public class Java {
22
void javaFun() {
33
new Kotlin().kotlinFun$main();
4+
KotlinKt.topLevelKotlinFun();
45
}
56
}

java/ql/test/kotlin/library-tests/java_and_kotlin_internal/Kotlin.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ public class Kotlin {
33
}
44
}
55

6+
internal fun topLevelKotlinFun() { }
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
isPublic
22
isInternal
33
| Kotlin.kt:2:11:3:2 | kotlinFun$main |
4+
| Kotlin.kt:6:10:6:36 | topLevelKotlinFun |
45
modifiers_methods
56
| file://:0:0:0:0 | final | Kotlin.kt:2:11:3:2 | kotlinFun$main |
7+
| file://:0:0:0:0 | final | Kotlin.kt:6:10:6:36 | topLevelKotlinFun |
68
| file://:0:0:0:0 | internal | Kotlin.kt:2:11:3:2 | kotlinFun$main |
9+
| file://:0:0:0:0 | internal | Kotlin.kt:6:10:6:36 | topLevelKotlinFun |
10+
| file://:0:0:0:0 | static | Kotlin.kt:6:10:6:36 | topLevelKotlinFun |
711
#select
812
| Kotlin.kt:2:11:3:2 | kotlinFun$main | final |
913
| Kotlin.kt:2:11:3:2 | kotlinFun$main | internal |
14+
| Kotlin.kt:6:10:6:36 | topLevelKotlinFun | final |
15+
| Kotlin.kt:6:10:6:36 | topLevelKotlinFun | internal |
16+
| Kotlin.kt:6:10:6:36 | topLevelKotlinFun | static |

0 commit comments

Comments
 (0)