Skip to content

Commit d9dc8e3

Browse files
committed
Fix binary names for classes declared from source
Only top-level non-class declarations need the IrFile's expected class name inserting
1 parent 910a1f8 commit d9dc8e3

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

java/kotlin-extractor/src/main/kotlin/utils/ClassNames.kt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,18 @@ fun getIrElementBinaryName(that: IrElement): String {
4444
is IrDeclarationWithName -> getName(that)
4545
else -> "(unknown-name)"
4646
}
47+
4748
val internalName = StringBuilder(shortName)
49+
if (that !is IrClass) {
50+
val parent = that.parent
51+
if (parent is IrFile) {
52+
// Note we'll fall through and do the IrPackageFragment case as well, since IrFile <: IrPackageFragment
53+
internalName.insert(0, getFileClassName(parent) + "$")
54+
}
55+
}
56+
4857
generateSequence(that.parent) { (it as? IrDeclaration)?.parent }
4958
.forEach {
50-
if (it is IrFile) {
51-
// Note we'll fall through and do the IrPackageFragment case as well, since IrFile <: IrPackageFragment
52-
internalName.insert(0, getFileClassName(it) + "$")
53-
}
5459
when (it) {
5560
is IrClass -> internalName.insert(0, getName(it) + "$")
5661
is IrPackageFragment -> it.fqName.asString().takeIf { fqName -> fqName.isNotEmpty() }?.let { fqName -> internalName.insert(0, "$fqName.") }

0 commit comments

Comments
 (0)