Skip to content

Commit 361e94d

Browse files
authored
Merge pull request #94 from Kotlin/nullability
Nullability + Datetime
2 parents fae804e + 2dda59f commit 361e94d

File tree

94 files changed

+996
-522
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+996
-522
lines changed

ggdsl-api/src/main/kotlin/org/jetbrains/kotlinx/ggdsl/dsl/Aes.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ public interface NonScalablePositionalAes : PositionalAes
4646
/**
4747
* Non-positional aesthetic attribute.
4848
*/
49-
public interface NonPositionalAes<in T : Any> : Aes
49+
public interface NonPositionalAes<in T> : Aes
5050

5151
/**
5252
* Non-positional aesthetic attribute that can be mapped with an explicit scale.
5353
*/
54-
public interface ScalableNonPositionalAes<in T : Any> : NonPositionalAes<T>, ScalableAes
54+
public interface ScalableNonPositionalAes<in T> : NonPositionalAes<T>, ScalableAes
5555

5656

5757
/**
5858
* Non-positional aesthetic attribute that can be mapped but without an explicit scale.
5959
*/
60-
public interface NonScalableNonPositionalAes<in T : Any> : NonPositionalAes<T>, MappableAes
60+
public interface NonScalableNonPositionalAes<in T> : NonPositionalAes<T>, MappableAes

ggdsl-api/src/main/kotlin/org/jetbrains/kotlinx/ggdsl/dsl/NamedData.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public data class NamedData(override val nameToValues: Map<String, TypedList>) :
1818
}
1919
public companion object {
2020
@PublishedApi
21-
internal fun fromUntyped(untypedMap: Map<String, List<Any>>): NamedData = NamedData(untypedMap.toTyped())
21+
internal fun fromUntyped(untypedMap: Map<String, List<*>>): NamedData = NamedData(untypedMap.toTyped())
2222
}
2323
}
2424

ggdsl-api/src/main/kotlin/org/jetbrains/kotlinx/ggdsl/dsl/column/columnPointer.kt

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import kotlin.reflect.KProperty
1616
* @param T the type of the column
1717
* @param id the name of the column
1818
*/
19-
public fun <T : Any> columnPointer(id: String): ColumnPointer<T> =
19+
public fun <T> columnPointer(id: String): ColumnPointer<T> =
2020
ColumnPointer(id)
2121

2222
/**
@@ -27,7 +27,7 @@ public fun <T : Any> columnPointer(id: String): ColumnPointer<T> =
2727
* @param T the type of the column
2828
* @receiver the name of the column
2929
*/
30-
public inline operator fun <reified T : Any> String.invoke(): ColumnPointer<T> =
30+
public inline operator fun <reified T> String.invoke(): ColumnPointer<T> =
3131
ColumnPointer(this)
3232

3333

@@ -45,7 +45,7 @@ public inline operator fun <reified T : Any> String.invoke(): ColumnPointer<T> =
4545
*
4646
* @property T the type of the column.
4747
*/
48-
public class UnnamedColumnPointer<T : Any> @PublishedApi internal constructor(){
48+
public class UnnamedColumnPointer<T> @PublishedApi internal constructor(){
4949
/**
5050
* Creates a [ColumnPointer] with `T` type and property name as a column name.
5151
*/
@@ -67,8 +67,8 @@ public class UnnamedColumnPointer<T : Any> @PublishedApi internal constructor(){
6767
*
6868
* @param T the type of the column
6969
*/
70-
public inline fun <reified T : Any> columnPointer(): UnnamedColumnPointer<T> =
70+
public inline fun <reified T> columnPointer(): UnnamedColumnPointer<T> =
7171
UnnamedColumnPointer()
7272

7373
@PublishedApi
74-
internal fun<T: Any> String.toColumnPointer(): ColumnPointer<T> = ColumnPointer(this)
74+
internal fun<T> String.toColumnPointer(): ColumnPointer<T> = ColumnPointer(this)

ggdsl-api/src/main/kotlin/org/jetbrains/kotlinx/ggdsl/dsl/columnScaled.kt

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import org.jetbrains.kotlinx.ggdsl.ir.scale.PositionalUnspecifiedScale
1919
* @param DomainType type of the domain.
2020
* @return scaled source.
2121
*/
22-
public fun <DomainType : Any> ColumnPointer<DomainType>.scaled(): ColumnScaledUnspecifiedDefault<DomainType> =
22+
public fun <DomainType> ColumnPointer<DomainType>.scaled(): ColumnScaledUnspecifiedDefault<DomainType> =
2323
ColumnScaledUnspecifiedDefault(this)
2424

2525
/**
@@ -30,7 +30,7 @@ public fun <DomainType : Any> ColumnPointer<DomainType>.scaled(): ColumnScaledUn
3030
* @param scale positional default scale.
3131
* @return scaled source.
3232
*/
33-
public fun <DomainType : Any> ColumnPointer<DomainType>.scaled(scale: PositionalUnspecifiedScale):
33+
public fun <DomainType> ColumnPointer<DomainType>.scaled(scale: PositionalUnspecifiedScale):
3434
ColumnScaledPositionalUnspecified<DomainType> =
3535
ColumnScaledPositionalUnspecified(this, scale)
3636

@@ -42,7 +42,7 @@ public fun <DomainType : Any> ColumnPointer<DomainType>.scaled(scale: Positional
4242
* @param scale non-positional default scale.
4343
* @return scaled source.
4444
*/
45-
public fun <DomainType : Any> ColumnPointer<DomainType>.scaled(scale: NonPositionalUnspecifiedScale):
45+
public fun <DomainType> ColumnPointer<DomainType>.scaled(scale: NonPositionalUnspecifiedScale):
4646
ColumnScaledNonPositionalUnspecified<DomainType> =
4747
ColumnScaledNonPositionalUnspecified(this, scale)
4848

@@ -53,7 +53,7 @@ public fun <DomainType : Any> ColumnPointer<DomainType>.scaled(scale: NonPositio
5353
* @param scale positional scale.
5454
* @return scaled source.
5555
*/
56-
public fun <DomainType : Any> ColumnPointer<DomainType>.scaled(
56+
public fun <DomainType> ColumnPointer<DomainType>.scaled(
5757
scale: PositionalScale<DomainType>
5858
): ColumnScaledPositional<DomainType> = ColumnScaledPositional(this, scale)
5959

@@ -64,6 +64,6 @@ public fun <DomainType : Any> ColumnPointer<DomainType>.scaled(
6464
* @param scale non-positional scale.
6565
* @return scaled source.
6666
*/
67-
public fun <DomainType : Any, RangeType : Any> ColumnPointer<DomainType>.scaled(
67+
public fun <DomainType, RangeType> ColumnPointer<DomainType>.scaled(
6868
scale: NonPositionalScale<DomainType, RangeType>
6969
): ColumnScaledNonPositional<DomainType, RangeType> = ColumnScaledNonPositional(this, scale)

ggdsl-api/src/main/kotlin/org/jetbrains/kotlinx/ggdsl/dsl/data.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class NamedDataBuilder {
1818
* @receiver a new column name.
1919
* @param list a new column values.
2020
*/
21-
public inline infix fun <reified T : Any> String.to(list: List<T>) {
21+
public inline infix fun <reified T> String.to(list: List<T>) {
2222
buffer[this] = TypedList(typeOf<T>(), list)
2323
}
2424
// TODO iterable and arrays

ggdsl-api/src/main/kotlin/org/jetbrains/kotlinx/ggdsl/dsl/freeScales.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import kotlin.reflect.typeOf
1616
* @param scale positional scale.
1717
* @return [FreePositionalScale]
1818
*/
19-
public inline operator fun <reified DomainType : Any> ScalablePositionalAes.invoke(
19+
public inline operator fun <reified DomainType> ScalablePositionalAes.invoke(
2020
scale: PositionalScale<DomainType>
2121
): FreePositionalScale<DomainType> {
2222
val freeScale = FreePositionalScale<DomainType>(
@@ -35,7 +35,7 @@ public inline operator fun <reified DomainType : Any> ScalablePositionalAes.invo
3535
* @param scale positional unspecified scale.
3636
* @return [FreePositionalScale]
3737
*/
38-
public inline operator fun <reified DomainType : Any> ScalablePositionalAes.invoke(
38+
public inline operator fun <reified DomainType> ScalablePositionalAes.invoke(
3939
scale: PositionalUnspecifiedScale
4040
): FreePositionalScale<DomainType> {
4141
val freeScale = FreePositionalScale<DomainType>(

ggdsl-api/src/main/kotlin/org/jetbrains/kotlinx/ggdsl/dsl/internal/contextsMutable.kt

+20-20
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public interface TableBindingContextInterfaceMutable : TableDataContext {
3838
* @param iterable converting [Iterable] that will be added as a column to context dataset.
3939
* @return [ColumnPointer] to a new column
4040
*/
41-
public inline fun <reified T : Any> TableBindingContextInterfaceMutable.toColumnPointer(iterable: Iterable<T>)
41+
public inline fun <reified T> TableBindingContextInterfaceMutable.toColumnPointer(iterable: Iterable<T>)
4242
: ColumnPointer<T> = toColumnPointer(iterable, generateID())
4343

4444
/**
@@ -50,7 +50,7 @@ public inline fun <reified T : Any> TableBindingContextInterfaceMutable.toColumn
5050
* @param id name of a new column.
5151
* @return [ColumnPointer] to a new column
5252
*/
53-
public inline fun <reified T : Any> TableBindingContextInterfaceMutable.toColumnPointer(
53+
public inline fun <reified T> TableBindingContextInterfaceMutable.toColumnPointer(
5454
iterable: Iterable<T>,
5555
id: String
5656
): ColumnPointer<T> {
@@ -82,7 +82,7 @@ public abstract class TableContextMutableBase : TableBindingContextInterfaceMuta
8282
* @param DomainType type of the domain.
8383
* @return scaled added column.
8484
*/
85-
public inline fun <reified DomainType : Any> Iterable<DomainType>.scaled(): ColumnScaledUnspecifiedDefault<DomainType> =
85+
public inline fun <reified DomainType> Iterable<DomainType>.scaled(): ColumnScaledUnspecifiedDefault<DomainType> =
8686
ColumnScaledUnspecifiedDefault(toColumnPointer(this))
8787

8888
/**
@@ -96,7 +96,7 @@ public abstract class TableContextMutableBase : TableBindingContextInterfaceMuta
9696
* @param DomainType type of the domain.
9797
* @return scaled added column.
9898
*/
99-
public inline fun <reified DomainType : Any> Pair<Iterable<DomainType>, String>.scaled()
99+
public inline fun <reified DomainType> Pair<Iterable<DomainType>, String>.scaled()
100100
: ColumnScaledUnspecifiedDefault<DomainType> =
101101
ColumnScaledUnspecifiedDefault(toColumnPointer(first, second))
102102

@@ -110,7 +110,7 @@ public abstract class TableContextMutableBase : TableBindingContextInterfaceMuta
110110
* @param scale applying positional unspecified scale.
111111
* @return scaled added column.
112112
*/
113-
public inline fun <reified DomainType : Any> Iterable<DomainType>.scaled(
113+
public inline fun <reified DomainType> Iterable<DomainType>.scaled(
114114
scale: PositionalUnspecifiedScale
115115
): ColumnScaledPositionalUnspecified<DomainType> = ColumnScaledPositionalUnspecified(toColumnPointer(this), scale)
116116

@@ -125,7 +125,7 @@ public abstract class TableContextMutableBase : TableBindingContextInterfaceMuta
125125
* @param scale applying positional unspecified scale.
126126
* @return scaled added column.
127127
*/
128-
public inline fun <reified DomainType : Any> Pair<Iterable<DomainType>, String>.scaled(
128+
public inline fun <reified DomainType> Pair<Iterable<DomainType>, String>.scaled(
129129
scale: PositionalUnspecifiedScale
130130
): ColumnScaledPositionalUnspecified<DomainType> =
131131
ColumnScaledPositionalUnspecified(toColumnPointer(first, second), scale)
@@ -140,7 +140,7 @@ public abstract class TableContextMutableBase : TableBindingContextInterfaceMuta
140140
* @param scale applying non-positional unspecified scale.
141141
* @return scaled added column.
142142
*/
143-
public inline fun <reified DomainType : Any> Iterable<DomainType>.scaled(
143+
public inline fun <reified DomainType> Iterable<DomainType>.scaled(
144144
scale: NonPositionalUnspecifiedScale
145145
): ColumnScaledNonPositionalUnspecified<DomainType> =
146146
ColumnScaledNonPositionalUnspecified(toColumnPointer(this), scale)
@@ -156,7 +156,7 @@ public abstract class TableContextMutableBase : TableBindingContextInterfaceMuta
156156
* @param scale applying non-positional unspecified scale.
157157
* @return scaled added column.
158158
*/
159-
public inline fun <reified DomainType : Any> Pair<Iterable<DomainType>, String>.scaled(
159+
public inline fun <reified DomainType> Pair<Iterable<DomainType>, String>.scaled(
160160
scale: NonPositionalUnspecifiedScale
161161
): ColumnScaledNonPositionalUnspecified<DomainType> =
162162
ColumnScaledNonPositionalUnspecified(toColumnPointer(first, second), scale)
@@ -170,7 +170,7 @@ public abstract class TableContextMutableBase : TableBindingContextInterfaceMuta
170170
* @param scale applying positional scale.
171171
* @return scaled added column.
172172
*/
173-
public inline fun <reified DomainType : Any> Iterable<DomainType>.scaled(
173+
public inline fun <reified DomainType> Iterable<DomainType>.scaled(
174174
scale: PositionalScale<DomainType>
175175
): ColumnScaledPositional<DomainType> = ColumnScaledPositional(toColumnPointer(this), scale)
176176

@@ -184,7 +184,7 @@ public abstract class TableContextMutableBase : TableBindingContextInterfaceMuta
184184
* @param scale applying positional scale.
185185
* @return scaled added column.
186186
*/
187-
public inline fun <reified DomainType : Any> Pair<Iterable<DomainType>, String>.scaled(
187+
public inline fun <reified DomainType> Pair<Iterable<DomainType>, String>.scaled(
188188
scale: PositionalScale<DomainType>
189189
): ColumnScaledPositional<DomainType> = ColumnScaledPositional(toColumnPointer(first, second), scale)
190190

@@ -197,7 +197,7 @@ public abstract class TableContextMutableBase : TableBindingContextInterfaceMuta
197197
* @param scale applying non-positional scale.
198198
* @return scaled added column.
199199
*/
200-
public inline fun <reified DomainType : Any, RangeType : Any> Iterable<DomainType>.scaled(
200+
public inline fun <reified DomainType, RangeType> Iterable<DomainType>.scaled(
201201
scale: NonPositionalScale<DomainType, RangeType>
202202
): ColumnScaledNonPositional<DomainType, RangeType> =
203203
ColumnScaledNonPositional(toColumnPointer(this), scale)
@@ -212,7 +212,7 @@ public abstract class TableContextMutableBase : TableBindingContextInterfaceMuta
212212
* @param scale applying non-positional scale.
213213
* @return scaled added column.
214214
*/
215-
public inline fun <reified DomainType : Any, RangeType : Any> Pair<Iterable<DomainType>, String>.scaled(
215+
public inline fun <reified DomainType, RangeType> Pair<Iterable<DomainType>, String>.scaled(
216216
scale: NonPositionalScale<DomainType, RangeType>
217217
): ColumnScaledNonPositional<DomainType, RangeType> =
218218
ColumnScaledNonPositional(toColumnPointer(first, second), scale)
@@ -223,7 +223,7 @@ public abstract class TableContextMutableBase : TableBindingContextInterfaceMuta
223223
*
224224
* @param iterable [Iterable] that will be added as a column.
225225
*/
226-
public inline operator fun <reified DomainType : Any> NonScalablePositionalAes.invoke(
226+
public inline operator fun <reified DomainType> NonScalablePositionalAes.invoke(
227227
iterable: Iterable<DomainType>
228228
) {
229229
context.bindingCollector.mappings[this.name] =
@@ -236,7 +236,7 @@ public abstract class TableContextMutableBase : TableBindingContextInterfaceMuta
236236
*
237237
* @param dataToName [Pair] of [Iterable] that will be added as a column to the name of a new column.
238238
*/
239-
public inline operator fun <reified DomainType : Any> NonScalablePositionalAes.invoke(
239+
public inline operator fun <reified DomainType> NonScalablePositionalAes.invoke(
240240
dataToName: Pair<Iterable<DomainType>, String>
241241
) {
242242
context.bindingCollector.mappings[this.name] =
@@ -251,7 +251,7 @@ public abstract class TableContextMutableBase : TableBindingContextInterfaceMuta
251251
*
252252
* @param iterable [Iterable] that will be added as a column.
253253
*/
254-
public inline operator fun <reified DomainType : Any, RangeType: Any>
254+
public inline operator fun <reified DomainType, RangeType>
255255
NonScalableNonPositionalAes<RangeType>.invoke(
256256
iterable: Iterable<DomainType>
257257
) {
@@ -267,7 +267,7 @@ public abstract class TableContextMutableBase : TableBindingContextInterfaceMuta
267267
*
268268
* @param dataToName [Pair] of [Iterable] that will be added as a column to the name of a new column.
269269
*/
270-
public inline operator fun <reified DomainType : Any, RangeType: Any>
270+
public inline operator fun <reified DomainType, RangeType>
271271
NonScalableNonPositionalAes<RangeType>.invoke(
272272
dataToName: Pair<Iterable<DomainType>, String>
273273
) {
@@ -284,7 +284,7 @@ public abstract class TableContextMutableBase : TableBindingContextInterfaceMuta
284284
*
285285
* @param iterable [Iterable] that will be added as a column.
286286
*/
287-
public inline operator fun <reified DomainType : Any> ScalablePositionalAes.invoke(
287+
public inline operator fun <reified DomainType> ScalablePositionalAes.invoke(
288288
iterable: Iterable<DomainType>
289289
): ScaledUnspecifiedDefaultPositionalMapping<DomainType> {
290290
val mapping = ScaledUnspecifiedDefaultPositionalMapping(
@@ -303,7 +303,7 @@ public abstract class TableContextMutableBase : TableBindingContextInterfaceMuta
303303
*
304304
* @param dataToName [Pair] of [Iterable] that will be added as a column to the name of a new column.
305305
*/
306-
public inline operator fun <reified DomainType : Any> ScalablePositionalAes.invoke(
306+
public inline operator fun <reified DomainType> ScalablePositionalAes.invoke(
307307
dataToName: Pair<Iterable<DomainType>, String>
308308
): ScaledUnspecifiedDefaultPositionalMapping<DomainType> {
309309
val mapping = ScaledUnspecifiedDefaultPositionalMapping(
@@ -322,7 +322,7 @@ public abstract class TableContextMutableBase : TableBindingContextInterfaceMuta
322322
*
323323
* @param iterable [Iterable] that will be added as a column.
324324
*/
325-
public inline operator fun <reified DomainType : Any, RangeType : Any>
325+
public inline operator fun <reified DomainType, RangeType>
326326
ScalableNonPositionalAes<RangeType>.invoke(
327327
iterable: Iterable<DomainType>
328328
): ScaledUnspecifiedDefaultNonPositionalMapping<DomainType, RangeType> {
@@ -342,7 +342,7 @@ public abstract class TableContextMutableBase : TableBindingContextInterfaceMuta
342342
*
343343
* @param dataToName [Pair] of [Iterable] that will be added as a column to the name of a new column.
344344
*/
345-
public inline operator fun <reified DomainType : Any, RangeType : Any>
345+
public inline operator fun <reified DomainType, RangeType>
346346
ScalableNonPositionalAes<RangeType>.invoke(
347347
dataToName: Pair<Iterable<DomainType>, String>
348348
): ScaledUnspecifiedDefaultNonPositionalMapping<DomainType, RangeType> {

ggdsl-api/src/main/kotlin/org/jetbrains/kotlinx/ggdsl/dsl/internal/mapToNamedData.kt

+16-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package org.jetbrains.kotlinx.ggdsl.dsl.internal
33
import kotlinx.datetime.Instant
44
import kotlinx.datetime.LocalDate
55
import kotlinx.datetime.LocalDateTime
6+
import kotlinx.datetime.LocalTime
67
import org.jetbrains.kotlinx.ggdsl.ir.data.TypedList
78
import kotlin.reflect.typeOf
89

@@ -11,7 +12,7 @@ import kotlin.reflect.typeOf
1112
*
1213
* @return [Map] with the same keys but with [TypedList] instead of untyped lists values.
1314
*/
14-
public fun Map<String, List<Any>>.toTyped(): Map<String, TypedList> {
15+
public fun Map<String, List<*>>.toTyped(): Map<String, TypedList> {
1516
return map { (key, list)-> key to list.toTypedList() }.toMap()
1617
}
1718

@@ -20,7 +21,7 @@ public fun Map<String, List<Any>>.toTyped(): Map<String, TypedList> {
2021
*
2122
* @return [TypedList] with the same values (with dynamic type inference).
2223
*/
23-
public fun List<Any>.toTypedList(): TypedList {
24+
public fun List<*>.toTypedList(): TypedList {
2425
val type = when {
2526
all { it is Int } -> typeOf<Int>()
2627
all { it is Long } -> typeOf<Long>()
@@ -32,7 +33,19 @@ public fun List<Any>.toTypedList(): TypedList {
3233
all { it is Instant } -> typeOf<Instant>()
3334
all { it is LocalDateTime } -> typeOf<LocalDateTime>()
3435
all { it is LocalDate } -> typeOf<LocalDate>()
35-
else -> typeOf<Any>() // todo
36+
all { it is LocalTime } -> typeOf<LocalTime>()
37+
all { it is Int? } -> typeOf<Int?>()
38+
all { it is Long? } -> typeOf<Long?>()
39+
all { it is Double? } -> typeOf<Double?>()
40+
all { it is Float? } -> typeOf<Float?>()
41+
all { it is Char? } -> typeOf<Char?>()
42+
all { it is Boolean? } -> typeOf<Boolean?>()
43+
all { it is String? } -> typeOf<String?>()
44+
all { it is Instant? } -> typeOf<Instant?>()
45+
all { it is LocalDateTime? } -> typeOf<LocalDateTime?>()
46+
all { it is LocalDate? } -> typeOf<LocalDate?>()
47+
all { it is LocalTime? } -> typeOf<LocalTime?>()
48+
else -> typeOf<Any?>() // todo
3649
}
3750
return TypedList(type, this)
3851
}

ggdsl-api/src/main/kotlin/org/jetbrains/kotlinx/ggdsl/dsl/internal/typed.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import kotlin.reflect.typeOf
1010
*
1111
* @return [TypedValue] with the given value and obtained [KType].
1212
*/
13-
public inline fun<reified T: Any> T.typed(): TypedValue{
13+
public inline fun<reified T> T.typed(): TypedValue{
1414
return TypedValue(typeOf<T>(), this)
1515
}
1616

@@ -19,7 +19,7 @@ public inline fun<reified T: Any> T.typed(): TypedValue{
1919
*
2020
* @return [Pair] of [TypedValue] with the given values and obtained [KType].
2121
*/
22-
public inline fun<reified T: Any> Pair<T, T>.typedPair(): Pair<TypedValue, TypedValue>{
22+
public inline fun<reified T> Pair<T, T>.typedPair(): Pair<TypedValue, TypedValue>{
2323
return TypedValue(typeOf<T>(), this.first) to TypedValue(typeOf<T>(), this.second)
2424
}
2525

@@ -28,6 +28,6 @@ public inline fun<reified T: Any> Pair<T, T>.typedPair(): Pair<TypedValue, Typed
2828
*
2929
* @return [TypedList] with the given values and obtained [KType].
3030
*/
31-
public inline fun<reified T: Any> List<T>.typedList(): TypedList{
31+
public inline fun<reified T> List<T>.typedList(): TypedList{
3232
return TypedList(typeOf<T>(), this)
3333
}

0 commit comments

Comments
 (0)