Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -54,7 +54,7 @@ internal object MarkersExtractor {

private fun getFields(markerClass: KClass<*>, nullableProperties: Boolean): List<GeneratedField> {
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<ColumnName>()?.name ?: fieldName.unquoted
val type = it.returnType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -239,9 +240,21 @@ class ConvertToTests {
.alsoDebug("df5 after second convert:")
}

private fun <T : DataFrame<*>> T.alsoDebug(println: String? = null): T = apply {
println?.let { println(it) }
print(borders = true, title = true, columnTypes = true, valueLimit = -1)
schema().print()
interface KeyValue<T> {
val key: String
val value: T
}

@DataSchema
interface MySchema : KeyValue<Int>

@Test
fun `Convert generic interface to itself`() {
val df = dataFrameOf("key", "value")(
"a", 1,
"b", 2,
).alsoDebug()
val converted = df.convertTo<MySchema>().alsoDebug()
converted shouldBe df
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -61,11 +60,10 @@ class ExtensionsGenerator(
return when {
isClassOrInterface() && effectivelyPublicOrInternal() -> {
DataSchemaDeclaration(
this,
declarations
.filterIsInstance<KSPropertyDeclaration>()
origin = this,
properties = getAllProperties()
.map { KSAnnotatedWithType(it, it.simpleName, it.type) }
.toList()
.toList(),
)
}
else -> null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> {
val key: String
val value: T
}

@DataSchema
interface MySchema : KeyValue<Int>


val ColumnsContainer<MySchema>.test1: DataColumn<String> get() = key
val DataRow<MySchema>.test2: Int get() = value
""".trimIndent()
)
)
)
)
result.successfulCompilation shouldBe true
}

@Test
fun `nested interface`() {
val result = KspCompilationTestRunner.compile(
Expand Down