From ad7d27154aa8831c559f4cdff388c35465ca0db3 Mon Sep 17 00:00:00 2001 From: Nikita Klimenko Date: Wed, 17 Apr 2024 18:03:09 +0300 Subject: [PATCH 1/2] fix "type checking has run into a recursive problem" related to #649 https://youtrack.jetbrains.com/issue/KT-65676/K2-type-checking-has-run-into-a-recursive-problem-for-property-with-same-name-as-class-on-classpath#focus=Comments-27-9726934.0-0 --- .../dataframe/impl/codeGen/CodeGeneratorImpl.kt | 10 +++++----- .../dataframe/impl/codeGen/CodeGeneratorImpl.kt | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/codeGen/CodeGeneratorImpl.kt b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/codeGen/CodeGeneratorImpl.kt index 73baaf8f0..e0a318dd6 100644 --- a/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/codeGen/CodeGeneratorImpl.kt +++ b/core/generated-sources/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/codeGen/CodeGeneratorImpl.kt @@ -107,11 +107,11 @@ internal interface TypeRenderingStrategy { internal object FullyQualifiedNames : TypeRenderingStrategy { - private val DataRow = DataRow::class.qualifiedName!! - private val ColumnsContainer = ColumnsContainer::class.qualifiedName!! - private val DataFrame = DataFrame::class.qualifiedName!! - private val DataColumn = DataColumn::class.qualifiedName!! - private val ColumnGroup = ColumnGroup::class.qualifiedName!! + private val DataRow = org.jetbrains.kotlinx.dataframe.DataRow::class.qualifiedName!! + private val ColumnsContainer = org.jetbrains.kotlinx.dataframe.ColumnsContainer::class.qualifiedName!! + private val DataFrame = org.jetbrains.kotlinx.dataframe.DataFrame::class.qualifiedName!! + private val DataColumn = org.jetbrains.kotlinx.dataframe.DataColumn::class.qualifiedName!! + private val ColumnGroup = org.jetbrains.kotlinx.dataframe.columns.ColumnGroup::class.qualifiedName!! override fun renderRowTypeName(markerName: String) = "$DataRow<$markerName>" diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/codeGen/CodeGeneratorImpl.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/codeGen/CodeGeneratorImpl.kt index 73baaf8f0..e0a318dd6 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/codeGen/CodeGeneratorImpl.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/codeGen/CodeGeneratorImpl.kt @@ -107,11 +107,11 @@ internal interface TypeRenderingStrategy { internal object FullyQualifiedNames : TypeRenderingStrategy { - private val DataRow = DataRow::class.qualifiedName!! - private val ColumnsContainer = ColumnsContainer::class.qualifiedName!! - private val DataFrame = DataFrame::class.qualifiedName!! - private val DataColumn = DataColumn::class.qualifiedName!! - private val ColumnGroup = ColumnGroup::class.qualifiedName!! + private val DataRow = org.jetbrains.kotlinx.dataframe.DataRow::class.qualifiedName!! + private val ColumnsContainer = org.jetbrains.kotlinx.dataframe.ColumnsContainer::class.qualifiedName!! + private val DataFrame = org.jetbrains.kotlinx.dataframe.DataFrame::class.qualifiedName!! + private val DataColumn = org.jetbrains.kotlinx.dataframe.DataColumn::class.qualifiedName!! + private val ColumnGroup = org.jetbrains.kotlinx.dataframe.columns.ColumnGroup::class.qualifiedName!! override fun renderRowTypeName(markerName: String) = "$DataRow<$markerName>" From 97c79e6a3cd8bdb6b66b88514941f51b62896ef7 Mon Sep 17 00:00:00 2001 From: Nikita Klimenko Date: Wed, 17 Apr 2024 18:03:49 +0300 Subject: [PATCH 2/2] migrate IR plugin to K2 compatible API --- .../dataframe/ExplainerIrTransformer.kt | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/plugins/expressions-converter/src/org/jetbrains/kotlinx/dataframe/ExplainerIrTransformer.kt b/plugins/expressions-converter/src/org/jetbrains/kotlinx/dataframe/ExplainerIrTransformer.kt index 98e704df3..d96e288af 100644 --- a/plugins/expressions-converter/src/org/jetbrains/kotlinx/dataframe/ExplainerIrTransformer.kt +++ b/plugins/expressions-converter/src/org/jetbrains/kotlinx/dataframe/ExplainerIrTransformer.kt @@ -13,8 +13,6 @@ import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin import org.jetbrains.kotlin.ir.declarations.IrField import org.jetbrains.kotlin.ir.declarations.IrFile import org.jetbrains.kotlin.ir.declarations.IrFunction -import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl -import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl import org.jetbrains.kotlin.ir.declarations.path import org.jetbrains.kotlin.ir.expressions.IrBlockBody import org.jetbrains.kotlin.ir.expressions.IrBody @@ -41,6 +39,8 @@ import org.jetbrains.kotlin.ir.util.isLocal import org.jetbrains.kotlin.ir.visitors.IrElementTransformer import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid +import org.jetbrains.kotlin.name.CallableId +import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import java.io.File @@ -125,6 +125,8 @@ class ExplainerIrTransformer( FqName("org.jetbrains.kotlinx.dataframe.DataRow") ) + val explainerPackage = FqName("org.jetbrains.kotlinx.dataframe.explainer") + override fun visitGetValue(expression: IrGetValue, data: ContainingDeclarations): IrExpression { if (expression.startOffset < 0) return expression if (expression.type.classFqName in dataFrameLike) { @@ -155,21 +157,20 @@ class ExplainerIrTransformer( return super.visitExpression(expression, data) } - @OptIn(FirIncompatiblePluginAPI::class) private fun transformDataFrameExpression( expression: IrDeclarationReference, ownerName: Name, receiver: IrExpression?, data: ContainingDeclarations ): IrCall { - val alsoReference = pluginContext.referenceFunctions(FqName("kotlin.also")).single() + val alsoReference = pluginContext.referenceFunctions(CallableId(FqName("kotlin"), Name.identifier("also"))).single() val result = IrCallImpl(-1, -1, expression.type, alsoReference, 1, 1).apply { this.extensionReceiver = expression putTypeArgument(0, expression.type) val symbol = IrSimpleFunctionSymbolImpl() - val alsoLambda = IrFunctionImpl( + val alsoLambda = pluginContext.irFactory.createSimpleFunction( startOffset = -1, endOffset = -1, origin = IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA, @@ -188,7 +189,7 @@ class ExplainerIrTransformer( ).apply { valueParameters = buildList { add( - IrValueParameterImpl( + pluginContext.irFactory.createValueParameter( startOffset = -1, endOffset = -1, origin = IrDeclarationOrigin.DEFINED, @@ -223,8 +224,12 @@ class ExplainerIrTransformer( add(IrConstImpl.int(-1, -1, pluginContext.irBuiltIns.intType, data.statementIndex)) } body = pluginContext.irFactory.createBlockBody(-1, -1).apply { - val callback = FqName("org.jetbrains.kotlinx.dataframe.explainer.PluginCallbackProxy.doAction") - val doAction = pluginContext.referenceFunctions(callback).single() + val callableId = CallableId( + explainerPackage, + FqName("PluginCallbackProxy"), + Name.identifier("doAction") + ) + val doAction = pluginContext.referenceFunctions(callableId).single() statements += IrCallImpl( startOffset = -1, endOffset = -1, @@ -233,7 +238,7 @@ class ExplainerIrTransformer( typeArgumentsCount = 0, valueArgumentsCount = valueArguments.size ).apply { - val clazz = FqName("org.jetbrains.kotlinx.dataframe.explainer.PluginCallbackProxy") + val clazz = ClassId(explainerPackage, Name.identifier("PluginCallbackProxy")) val plugin = pluginContext.referenceClass(clazz)!! dispatchReceiver = IrGetObjectValueImpl(-1, -1, plugin.defaultType, plugin) valueArguments.forEachIndexed { i, argument ->