Skip to content

Commit 072ed60

Browse files
committed
Properly expose withValuesImpl to remove INSIVIBLE_REFERENCE from compiler plugin
1 parent 0b222e6 commit 072ed60

File tree

4 files changed

+21
-6
lines changed

4 files changed

+21
-6
lines changed

core/api/core.api

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5757,6 +5757,10 @@ public final class org/jetbrains/kotlinx/dataframe/impl/aggregation/receivers/Ag
57575757
public static final fun internal (Lorg/jetbrains/kotlinx/dataframe/aggregation/AggregateDsl;)Lorg/jetbrains/kotlinx/dataframe/impl/aggregation/receivers/AggregateInternalDsl;
57585758
}
57595759

5760+
public final class org/jetbrains/kotlinx/dataframe/impl/api/ConstructorsKt {
5761+
public static final fun withValuesImpl (Lkotlin/Pair;)Ljava/util/List;
5762+
}
5763+
57605764
public final class org/jetbrains/kotlinx/dataframe/impl/api/ConvertKt {
57615765
public static final fun convertRowColumnImpl (Lorg/jetbrains/kotlinx/dataframe/api/Convert;Lkotlin/reflect/KType;Lorg/jetbrains/kotlinx/dataframe/api/Infer;Lkotlin/jvm/functions/Function2;)Lorg/jetbrains/kotlinx/dataframe/DataFrame;
57625766
public static final fun withRowCellImpl (Lorg/jetbrains/kotlinx/dataframe/api/Convert;Lkotlin/reflect/KType;Lorg/jetbrains/kotlinx/dataframe/api/Infer;Lkotlin/jvm/functions/Function2;)Lorg/jetbrains/kotlinx/dataframe/DataFrame;

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/constructors.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ public class DataFrameBuilder(private val header: List<String>) {
393393

394394
@JvmName("invoke1")
395395
internal fun withValues(values: Iterable<Any?>): DataFrame<*> =
396-
withValuesImpl(header, values.asList()).map { (name, values) ->
396+
(header to values.asList()).withValuesImpl().map { (name, values) ->
397397
DataColumn.createByInference(name, values)
398398
}.toDataFrame()
399399

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/api/constructors.kt

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
package org.jetbrains.kotlinx.dataframe.impl.api
22

3-
internal fun <T> withValuesImpl(header: List<String>, values: List<T>): List<Pair<String, List<T>>> {
3+
import org.jetbrains.kotlinx.dataframe.exceptions.DataFrameException
4+
5+
/**
6+
* Public API to be re-used in compiler plugin implementation
7+
*/
8+
public fun <T> Pair<List<String>, List<T>>.withValuesImpl(): List<Pair<String, List<T>>> {
9+
val (header, values) = this
410
val ncol = header.size
511

6-
require(header.isNotEmpty() && values.size.rem(ncol) == 0) {
7-
"Number of values ${values.size} is not divisible by number of columns $ncol"
12+
if (!(header.isNotEmpty() && values.size.rem(ncol) == 0)) {
13+
throw WrongNumberOfValuesException(values.size, ncol)
814
}
915

1016
val nrow = values.size / ncol
@@ -16,3 +22,9 @@ internal fun <T> withValuesImpl(header: List<String>, values: List<T>): List<Pai
1622
header[col] to colValues
1723
}
1824
}
25+
26+
internal class WrongNumberOfValuesException(size: Int, ncol: Int) :
27+
IllegalArgumentException(),
28+
DataFrameException {
29+
override val message = "Number of values $size is not divisible by number of columns $ncol"
30+
}

plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/impl/api/dataFrameOf.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
21
package org.jetbrains.kotlinx.dataframe.plugin.impl.api
32

43
import org.jetbrains.kotlin.fir.expressions.FirExpression
@@ -35,7 +34,7 @@ class DataFrameBuilderInvoke0 : AbstractSchemaModificationInterpreter() {
3534
val Arguments.values: FirVarargArgumentsExpression by arg(lens = Interpreter.Id)
3635

3736
override fun Arguments.interpret(): PluginDataFrameSchema {
38-
val columns = withValuesImpl(receiver.header, values.arguments).map { (name, values) ->
37+
val columns = (receiver.header to values.arguments).withValuesImpl().map { (name, values) ->
3938
val type = session.typeContext.commonSuperTypeOrNull(values.map { it.resolvedType }) ?: error("$name $values")
4039
simpleColumnOf(name, type)
4140
}

0 commit comments

Comments
 (0)