Skip to content

Commit 0093659

Browse files
committed
test and bugfix for convertTo etc. not recognizing super properties correctly
1 parent 089e802 commit 0093659

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/codeGen/MarkersExtractor.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import org.jetbrains.kotlinx.dataframe.impl.schema.getPropertiesOrder
88
import org.jetbrains.kotlinx.dataframe.schema.ColumnSchema
99
import kotlin.reflect.KClass
1010
import kotlin.reflect.KType
11-
import kotlin.reflect.full.declaredMemberProperties
1211
import kotlin.reflect.full.findAnnotation
1312
import kotlin.reflect.full.hasAnnotation
13+
import kotlin.reflect.full.memberProperties
1414
import kotlin.reflect.full.superclasses
1515
import kotlin.reflect.full.withNullability
1616
import kotlin.reflect.jvm.jvmErasure
@@ -54,7 +54,7 @@ internal object MarkersExtractor {
5454

5555
private fun getFields(markerClass: KClass<*>, nullableProperties: Boolean): List<GeneratedField> {
5656
val order = getPropertiesOrder(markerClass)
57-
return markerClass.declaredMemberProperties.sortedBy { order[it.name] ?: Int.MAX_VALUE }.mapIndexed { _, it ->
57+
return markerClass.memberProperties.sortedBy { order[it.name] ?: Int.MAX_VALUE }.mapIndexed { _, it ->
5858
val fieldName = ValidFieldName.of(it.name)
5959
val columnName = it.findAnnotation<ColumnName>()?.name ?: fieldName.unquoted
6060
val type = it.returnType

core/src/test/kotlin/org/jetbrains/kotlinx/dataframe/api/convertTo.kt

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import io.kotest.assertions.throwables.shouldThrow
44
import io.kotest.matchers.shouldBe
55
import org.jetbrains.kotlinx.dataframe.AnyFrame
66
import org.jetbrains.kotlinx.dataframe.DataFrame
7+
import org.jetbrains.kotlinx.dataframe.alsoDebug
78
import org.jetbrains.kotlinx.dataframe.annotations.DataSchema
89
import org.jetbrains.kotlinx.dataframe.exceptions.TypeConverterNotFoundException
910
import org.junit.Test
@@ -239,9 +240,21 @@ class ConvertToTests {
239240
.alsoDebug("df5 after second convert:")
240241
}
241242

242-
private fun <T : DataFrame<*>> T.alsoDebug(println: String? = null): T = apply {
243-
println?.let { println(it) }
244-
print(borders = true, title = true, columnTypes = true, valueLimit = -1)
245-
schema().print()
243+
interface KeyValue<T> {
244+
val key: String
245+
val value: T
246+
}
247+
248+
@DataSchema
249+
interface MySchema : KeyValue<Int>
250+
251+
@Test
252+
fun `Convert generic interface to itself`() {
253+
val df = dataFrameOf("key", "value")(
254+
"a", 1,
255+
"b", 2,
256+
).alsoDebug()
257+
val converted = df.convertTo<MySchema>().alsoDebug()
258+
converted shouldBe df
246259
}
247260
}

0 commit comments

Comments
 (0)