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<*>> =
228
228
.let {
229
229
when {
230
230
// 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 ])
232
232
233
233
else ->
234
234
it.fold(null as (Set <KClass <* >>? )) { set, clazz ->
235
235
// 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()
240
239
set?.intersect(superclasses) ? : superclasses
241
240
}!! .let {
242
241
// 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 1
1
package org.jetbrains.kotlinx.dataframe.api
2
2
3
3
import io.kotest.matchers.shouldBe
4
+ import org.jetbrains.kotlinx.dataframe.DataFrame
4
5
import org.jetbrains.kotlinx.dataframe.impl.nothingType
5
6
import org.jetbrains.kotlinx.dataframe.type
6
7
import org.junit.Test
8
+ import kotlin.reflect.typeOf
7
9
8
10
class ConstructorsTests {
9
11
@@ -32,4 +34,21 @@ class ConstructorsTests {
32
34
dataFrameOf(" a" to emptyList())[" a" ].type shouldBe nothingType(false )
33
35
dataFrameOf(" a" to listOf (null ))[" a" ].type shouldBe nothingType(true )
34
36
}
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
+ }
35
54
}
You can’t perform that action at this time.
0 commit comments