Fix binary names for classes declared from source

Only top-level non-class declarations need the IrFile's expected class name inserting
This commit is contained in:
Chris Smowton
2022-12-02 17:05:04 +00:00
parent 910a1f872d
commit d9dc8e38f9

View File

@@ -44,13 +44,18 @@ fun getIrElementBinaryName(that: IrElement): String {
is IrDeclarationWithName -> getName(that)
else -> "(unknown-name)"
}
val internalName = StringBuilder(shortName)
if (that !is IrClass) {
val parent = that.parent
if (parent is IrFile) {
// Note we'll fall through and do the IrPackageFragment case as well, since IrFile <: IrPackageFragment
internalName.insert(0, getFileClassName(parent) + "$")
}
}
generateSequence(that.parent) { (it as? IrDeclaration)?.parent }
.forEach {
if (it is IrFile) {
// Note we'll fall through and do the IrPackageFragment case as well, since IrFile <: IrPackageFragment
internalName.insert(0, getFileClassName(it) + "$")
}
when (it) {
is IrClass -> internalName.insert(0, getName(it) + "$")
is IrPackageFragment -> it.fqName.asString().takeIf { fqName -> fqName.isNotEmpty() }?.let { fqName -> internalName.insert(0, "$fqName.") }