5
5
6
6
package org.jetbrains.kotlinx.dataframe.plugin.extensions
7
7
8
- import kotlinx.serialization.decodeFromString
9
8
import kotlinx.serialization.encodeToString
10
9
import kotlinx.serialization.json.Json
11
10
import org.jetbrains.kotlin.backend.common.FileLoweringPass
@@ -18,8 +17,10 @@ import org.jetbrains.kotlin.ir.backend.js.utils.valueArguments
18
17
import org.jetbrains.kotlin.ir.declarations.IrClass
19
18
import org.jetbrains.kotlin.ir.declarations.IrConstructor
20
19
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
20
+ import org.jetbrains.kotlin.ir.declarations.IrDeclarationWithName
21
21
import org.jetbrains.kotlin.ir.declarations.IrFile
22
22
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
23
+ import org.jetbrains.kotlin.ir.declarations.IrPackageFragment
23
24
import org.jetbrains.kotlin.ir.declarations.IrProperty
24
25
import org.jetbrains.kotlin.ir.declarations.copyAttributes
25
26
import org.jetbrains.kotlin.ir.declarations.createBlockBody
@@ -175,8 +176,9 @@ private class DataFrameFileLowering(val context: IrPluginContext) : FileLowering
175
176
176
177
val constructors = context.referenceConstructors(ClassId (FqName (" kotlin.jvm" ), Name .identifier(" JvmName" )))
177
178
val jvmName = constructors.single { it.owner.valueParameters.size == 1 }
178
- val markerName = ((getter.extensionReceiverParameter!! .type as IrSimpleType ).arguments.single() as IrSimpleType ).classFqName?.shortName()!!
179
- val jvmNameArg = " ${markerName.identifier} _${declaration.name.identifier} "
179
+ val marker =
180
+ ((getter.extensionReceiverParameter!! .type as IrSimpleType ).arguments.single() as IrSimpleType ).classOrFail.owner
181
+ val jvmNameArg = " ${marker.nestedName()} _${declaration.name.identifier} "
180
182
getter.annotations = listOf (
181
183
IrConstructorCallImpl (- 1 , - 1 , jvmName.owner.returnType, jvmName, 0 , 0 , 1 )
182
184
.also {
@@ -218,6 +220,21 @@ private class DataFrameFileLowering(val context: IrPluginContext) : FileLowering
218
220
return declaration
219
221
}
220
222
223
+ private fun IrDeclarationWithName.nestedName () = buildString { computeNestedName(this @nestedName, this ) }
224
+
225
+ private fun computeNestedName (declaration : IrDeclarationWithName , result : StringBuilder ): Boolean {
226
+ when (val parent = declaration.parent) {
227
+ is IrClass -> {
228
+ if (! computeNestedName(parent, result)) return false
229
+ }
230
+ is IrPackageFragment -> {}
231
+ else -> return false
232
+ }
233
+ if (result.isNotEmpty()) result.append(' _' )
234
+ result.append(declaration.name.asString())
235
+ return true
236
+ }
237
+
221
238
@OptIn(UnsafeDuringIrConstructionAPI ::class )
222
239
override fun visitErrorCallExpression (expression : IrErrorCallExpression ): IrExpression {
223
240
val origin = (expression.type.classifierOrNull?.owner as ? IrClass )?.origin ? : return expression
0 commit comments