diff --git a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/codeGen/MarkersExtractor.kt b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/codeGen/MarkersExtractor.kt index 37f5e39476..ef883a33e9 100644 --- a/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/codeGen/MarkersExtractor.kt +++ b/core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/codeGen/MarkersExtractor.kt @@ -8,9 +8,9 @@ import org.jetbrains.kotlinx.dataframe.impl.schema.getPropertiesOrder import org.jetbrains.kotlinx.dataframe.schema.ColumnSchema import kotlin.reflect.KClass import kotlin.reflect.KType -import kotlin.reflect.full.declaredMemberProperties import kotlin.reflect.full.findAnnotation import kotlin.reflect.full.hasAnnotation +import kotlin.reflect.full.memberProperties import kotlin.reflect.full.superclasses import kotlin.reflect.full.withNullability import kotlin.reflect.jvm.jvmErasure @@ -54,7 +54,7 @@ internal object MarkersExtractor { private fun getFields(markerClass: KClass<*>, nullableProperties: Boolean): List { val order = getPropertiesOrder(markerClass) - return markerClass.declaredMemberProperties.sortedBy { order[it.name] ?: Int.MAX_VALUE }.mapIndexed { _, it -> + return markerClass.memberProperties.sortedBy { order[it.name] ?: Int.MAX_VALUE }.mapIndexed { _, it -> val fieldName = ValidFieldName.of(it.name) val columnName = it.findAnnotation()?.name ?: fieldName.unquoted val type = it.returnType diff --git a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/api/convertTo.kt b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/api/convertTo.kt index 2fe735686d..fb9ffe3a4e 100644 --- a/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/api/convertTo.kt +++ b/core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/api/convertTo.kt @@ -4,6 +4,7 @@ import io.kotest.assertions.throwables.shouldThrow import io.kotest.matchers.shouldBe import org.jetbrains.kotlinx.dataframe.AnyFrame import org.jetbrains.kotlinx.dataframe.DataFrame +import org.jetbrains.kotlinx.dataframe.alsoDebug import org.jetbrains.kotlinx.dataframe.annotations.DataSchema import org.jetbrains.kotlinx.dataframe.exceptions.TypeConverterNotFoundException import org.junit.Test @@ -239,9 +240,21 @@ class ConvertToTests { .alsoDebug("df5 after second convert:") } - private fun > T.alsoDebug(println: String? = null): T = apply { - println?.let { println(it) } - print(borders = true, title = true, columnTypes = true, valueLimit = -1) - schema().print() + interface KeyValue { + val key: String + val value: T + } + + @DataSchema + interface MySchema : KeyValue + + @Test + fun `Convert generic interface to itself`() { + val df = dataFrameOf("key", "value")( + "a", 1, + "b", 2, + ).alsoDebug() + val converted = df.convertTo().alsoDebug() + converted shouldBe df } } diff --git a/plugins/symbol-processor/src/main/kotlin/org/jetbrains/dataframe/ksp/ExtensionsGenerator.kt b/plugins/symbol-processor/src/main/kotlin/org/jetbrains/dataframe/ksp/ExtensionsGenerator.kt index ab819c3610..4ff61809fb 100644 --- a/plugins/symbol-processor/src/main/kotlin/org/jetbrains/dataframe/ksp/ExtensionsGenerator.kt +++ b/plugins/symbol-processor/src/main/kotlin/org/jetbrains/dataframe/ksp/ExtensionsGenerator.kt @@ -12,7 +12,6 @@ import com.google.devtools.ksp.symbol.KSClassifierReference import com.google.devtools.ksp.symbol.KSDeclaration import com.google.devtools.ksp.symbol.KSFile import com.google.devtools.ksp.symbol.KSName -import com.google.devtools.ksp.symbol.KSPropertyDeclaration import com.google.devtools.ksp.symbol.KSTypeReference import com.google.devtools.ksp.symbol.KSValueArgument import com.google.devtools.ksp.symbol.Modifier @@ -61,11 +60,10 @@ class ExtensionsGenerator( return when { isClassOrInterface() && effectivelyPublicOrInternal() -> { DataSchemaDeclaration( - this, - declarations - .filterIsInstance() + origin = this, + properties = getAllProperties() .map { KSAnnotatedWithType(it, it.simpleName, it.type) } - .toList() + .toList(), ) } else -> null diff --git a/plugins/symbol-processor/src/test/kotlin/org/jetbrains/dataframe/ksp/DataFrameSymbolProcessorTest.kt b/plugins/symbol-processor/src/test/kotlin/org/jetbrains/dataframe/ksp/DataFrameSymbolProcessorTest.kt index b24c2ebfee..1ae23e7066 100644 --- a/plugins/symbol-processor/src/test/kotlin/org/jetbrains/dataframe/ksp/DataFrameSymbolProcessorTest.kt +++ b/plugins/symbol-processor/src/test/kotlin/org/jetbrains/dataframe/ksp/DataFrameSymbolProcessorTest.kt @@ -706,6 +706,37 @@ class DataFrameSymbolProcessorTest { result.successfulCompilation shouldBe true } + @Test + fun `generic interface as supertype`() { + val result = KspCompilationTestRunner.compile( + TestCompilationParameters( + sources = listOf( + SourceFile.kotlin( + "MySources.kt", + """ + package org.example + + $imports + + interface KeyValue { + val key: String + val value: T + } + + @DataSchema + interface MySchema : KeyValue + + + val ColumnsContainer.test1: DataColumn get() = key + val DataRow.test2: Int get() = value + """.trimIndent() + ) + ) + ) + ) + result.successfulCompilation shouldBe true + } + @Test fun `nested interface`() { val result = KspCompilationTestRunner.compile(