File tree Expand file tree Collapse file tree 2 files changed +23
-5
lines changed
main/kotlin/org/jetbrains/kotlinx/dataframe/impl
test/kotlin/org/jetbrains/kotlinx/dataframe/api Expand file tree Collapse file tree 2 files changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -228,15 +228,14 @@ internal fun commonParents(classes: Iterable<KClass<*>>): List<KClass<*>> =
228228 .let {
229229 when {
230230 // if there is only one class - return it
231- it.size == 1 && it[0 ].visibility == KVisibility .PUBLIC -> listOf (it[0 ])
231+ it.size == 1 && it[0 ].visibility. let { it == null || it == KVisibility .PUBLIC } -> listOf (it[0 ])
232232
233233 else ->
234234 it.fold(null as (Set <KClass <* >>? )) { set, clazz ->
235235 // collect a set of all common superclasses from original classes
236- val superclasses =
237- (clazz.allSuperclasses + clazz)
238- .filter { it.visibility == KVisibility .PUBLIC }
239- .toSet()
236+ val superclasses = (clazz.allSuperclasses + clazz)
237+ .filter { it.visibility == null || it.visibility == KVisibility .PUBLIC }
238+ .toSet()
240239 set?.intersect(superclasses) ? : superclasses
241240 }!! .let {
242241 // leave only 'leaf' classes, that are not super to some other class in a set
Original file line number Diff line number Diff line change 11package org.jetbrains.kotlinx.dataframe.api
22
33import io.kotest.matchers.shouldBe
4+ import org.jetbrains.kotlinx.dataframe.DataFrame
45import org.jetbrains.kotlinx.dataframe.impl.nothingType
56import org.jetbrains.kotlinx.dataframe.type
67import org.junit.Test
8+ import kotlin.reflect.typeOf
79
810class ConstructorsTests {
911
@@ -32,4 +34,21 @@ class ConstructorsTests {
3234 dataFrameOf(" a" to emptyList())[" a" ].type shouldBe nothingType(false )
3335 dataFrameOf(" a" to listOf (null ))[" a" ].type shouldBe nothingType(true )
3436 }
37+
38+ @Suppress(" ktlint:standard:argument-list-wrapping" )
39+ @Test
40+ fun `dataFrameOf with local class` () {
41+ data class Car (val type : String , val model : String )
42+
43+ val cars: DataFrame <* > = dataFrameOf(" owner" , " car" )(
44+ " Max" , Car (" audi" , " a8" ),
45+ " Tom" , Car (" toyota" , " corolla" ),
46+ )
47+
48+ cars[" car" ].type shouldBe typeOf<Car >()
49+
50+ val unfolded = cars.unfold(" car" )
51+ unfolded[" car" ][" type" ].type shouldBe typeOf<String >()
52+ unfolded[" car" ][" model" ].type shouldBe typeOf<String >()
53+ }
3554}
You can’t perform that action at this time.
0 commit comments