Skip to content

Commit

Permalink
Merge pull request #740 from Kotlin/compiler-plugin-fixes
Browse files Browse the repository at this point in the history
Compiler plugin fixes
  • Loading branch information
koperagen authored Jun 17, 2024
2 parents e418f9b + 91fa075 commit bff6e3c
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ fun KotlinTypeFacade.analyzeRefinedCallShape(call: FirFunctionCall, reporter: In
return null
}

val newSchema: PluginDataFrameSchema = call.interpreterName(session)?.let {
when (it) {
val newSchema: PluginDataFrameSchema = call.interpreterName(session)?.let { name ->
when (name) {
"toDataFrameDsl" -> {
val list = call.argumentList as FirResolvedArgumentList
val lambda = (list.arguments.singleOrNull() as? FirAnonymousFunctionExpression)?.anonymousFunction
Expand Down Expand Up @@ -85,7 +85,7 @@ fun KotlinTypeFacade.analyzeRefinedCallShape(call: FirFunctionCall, reporter: In
PluginDataFrameSchema(emptyList())
}
}
else -> it.load<Interpreter<*>>().let { processor ->
else -> name.load<Interpreter<*>>().let { processor ->
val dataFrameSchema = interpret(call, processor, reporter = reporter)
.let {
val value = it?.value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,6 @@ interface KotlinTypeFacade {

fun Marker.type() = type

val anyDataFrame get() = ConeClassLikeTypeImpl(
ConeClassLikeLookupTagImpl(Names.DF_CLASS_ID),
typeArguments = arrayOf(session.builtinTypes.anyType.type),
isNullable = false
).wrap()

val anyRow get() = ConeClassLikeTypeImpl(
ConeClassLikeLookupTagImpl(Names.DATA_ROW_CLASS_ID),
typeArguments = arrayOf(session.builtinTypes.anyType.type),
isNullable = false
).wrap()

fun from(type: KType): Marker {
return Marker(fromImpl(type))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:Suppress("INVISIBLE_REFERENCE", "CANNOT_OVERRIDE_INVISIBLE_MEMBER")

package org.jetbrains.kotlinx.dataframe.plugin.impl

import org.jetbrains.kotlin.fir.types.ConeKotlinType
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")

package org.jetbrains.kotlinx.dataframe.plugin.impl.api

import org.jetbrains.kotlinx.dataframe.plugin.impl.AbstractInterpreter
Expand All @@ -9,7 +11,6 @@ import org.jetbrains.kotlinx.dataframe.api.Infer
import org.jetbrains.kotlinx.dataframe.api.pathOf
import org.jetbrains.kotlinx.dataframe.api.toPath
import org.jetbrains.kotlinx.dataframe.impl.api.GenericColumnsToInsert
import org.jetbrains.kotlinx.dataframe.impl.api.GenericColumnGroup
import org.jetbrains.kotlinx.dataframe.impl.api.insertImplGenericContainer
import org.jetbrains.kotlinx.dataframe.plugin.impl.PluginDataFrameSchema
import org.jetbrains.kotlinx.dataframe.plugin.impl.SimpleCol
Expand Down Expand Up @@ -81,7 +82,7 @@ internal class Under0 : AbstractInterpreter<PluginDataFrameSchema>() {
val Arguments.receiver: InsertClauseApproximation by insertClause()

override fun Arguments.interpret(): PluginDataFrameSchema {
return receiver.df.insertImpl(listOf(GenericColumnsToInsert(column.path.path.toPath(), receiver.column)), anyDataFrame)
return receiver.df.insertImpl(listOf(GenericColumnsToInsert(column.path.path.toPath(), receiver.column)))
}
}

Expand All @@ -90,7 +91,7 @@ internal class Under1 : AbstractInterpreter<PluginDataFrameSchema>() {
val Arguments.receiver: InsertClauseApproximation by insertClause()

override fun Arguments.interpret(): PluginDataFrameSchema {
return receiver.df.insertImpl(listOf(GenericColumnsToInsert(columnPath.path.toPath(), receiver.column)), anyRow)
return receiver.df.insertImpl(listOf(GenericColumnsToInsert(columnPath.path.toPath(), receiver.column)))
}
}

Expand All @@ -99,7 +100,7 @@ internal class Under2 : AbstractInterpreter<PluginDataFrameSchema>() {
val Arguments.receiver: InsertClauseApproximation by insertClause()

override fun Arguments.interpret(): PluginDataFrameSchema {
return receiver.df.insertImpl(listOf(GenericColumnsToInsert(pathOf(column.name), receiver.column)), anyRow)
return receiver.df.insertImpl(listOf(GenericColumnsToInsert(pathOf(column.name), receiver.column)))
}
}

Expand All @@ -108,7 +109,7 @@ internal class Under3 : AbstractInterpreter<PluginDataFrameSchema>() {
val Arguments.receiver: InsertClauseApproximation by insertClause()

override fun Arguments.interpret(): PluginDataFrameSchema {
return receiver.df.insertImpl(listOf(GenericColumnsToInsert(pathOf(column.name), receiver.column)), anyRow)
return receiver.df.insertImpl(listOf(GenericColumnsToInsert(pathOf(column.name), receiver.column)))
}
}

Expand All @@ -117,16 +118,15 @@ internal class Under4 : AbstractInterpreter<PluginDataFrameSchema>() {
val Arguments.receiver: InsertClauseApproximation by insertClause()

override fun Arguments.interpret(): PluginDataFrameSchema {
return receiver.df.insertImpl(listOf(GenericColumnsToInsert(pathOf(column), receiver.column)), anyRow)
return receiver.df.insertImpl(listOf(GenericColumnsToInsert(pathOf(column), receiver.column)))
}
}

@PublishedApi
internal fun PluginDataFrameSchema.insertImpl(
columns: List<GenericColumnsToInsert<SimpleCol>>,
columnGroupType: TypeApproximation
columns: List<GenericColumnsToInsert<SimpleCol>>
): PluginDataFrameSchema {
return insertImplGenericContainer<PluginDataFrameSchema, SimpleCol, GenericColumnGroup<SimpleCol>>(
return insertImplGenericContainer(
this,
columns,
columns.firstOrNull()?.referenceNode?.getRoot(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")

package org.jetbrains.kotlinx.dataframe.plugin.impl.api

import org.jetbrains.kotlinx.dataframe.plugin.impl.AbstractInterpreter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ val KotlinTypeFacade.toPluginDataFrameSchema: DataFrameSchema.() -> PluginDataFr
)
}



val KotlinTypeFacade.deserializeToPluginDataFrameSchema: SerializableSchema.() -> PluginDataFrameSchema
get() = {
PluginDataFrameSchema(
Expand Down Expand Up @@ -155,7 +153,6 @@ private fun from(type: KType): SerializableKType {
return serializableKType
}


private fun List<KTypeProjection>.mapToConeTypeProjection(): List<TypeProjection> = List(size) {
val typeProjection = get(it)
val type = typeProjection.type
Expand Down Expand Up @@ -189,7 +186,6 @@ private fun List<TypeProjection>.mapToConeTypeProjection(): Array<out ConeTypePr
}
}


fun KType.from(): String {
val classifier = classifier ?: error("")
val klass = classifier as? KClass<*> ?: error("")
Expand Down

0 comments on commit bff6e3c

Please sign in to comment.