Cleanup type variance in Task builder

This commit is contained in:
Alexander Nozik 2020-04-13 15:34:26 +03:00
parent f67fb63c45
commit 0434360d46
4 changed files with 14 additions and 8 deletions

View File

@ -31,7 +31,7 @@ class MapActionBuilder<T, R>(var name: Name, var meta: MetaBuilder, val actionMe
class MapAction<T : Any, out R : Any>(
val inputType: KClass<out T>,
val inputType: KClass<T>,
val outputType: KClass<out R>,
private val block: MapActionBuilder<T, R>.() -> Unit
) : Action<T, R> {

View File

@ -72,7 +72,7 @@ class ReduceGroupBuilder<T : Any, R : Any>(val actionMeta: Meta) {
* The same rules as for KPipe
*/
class ReduceAction<T : Any, R : Any>(
val inputType: KClass<out T>,
val inputType: KClass<T>,
val outputType: KClass<out R>,
private val action: ReduceGroupBuilder<T, R>.() -> Unit
) : Action<T, R> {

View File

@ -33,7 +33,7 @@ class SplitBuilder<T : Any, R : Any>(val name: Name, val meta: Meta) {
}
class SplitAction<T : Any, R : Any>(
val inputType: KClass<out T>,
val inputType: KClass<T>,
val outputType: KClass<out R>,
private val action: SplitBuilder<T, R>.() -> Unit
) : Action<T, R> {

View File

@ -16,6 +16,7 @@ import kotlin.reflect.KClass
@DFBuilder
class TaskBuilder<R : Any>(val name: Name, val type: KClass<out R>) {
private var modelTransform: TaskModelBuilder.(Meta) -> Unit = { allData() }
// private val additionalDependencies = HashSet<Dependency>()
var descriptor: NodeDescriptor? = null
private val dataTransforms: MutableList<DataTransformation> = ArrayList()
@ -113,10 +114,13 @@ class TaskBuilder<R : Any>(val name: Name, val type: KClass<out R>) {
crossinline block: MapActionBuilder<T, R>.(TaskEnv) -> Unit
) {
action(from, to) {
val env = this
MapAction(
inputType = T::class,
outputType = type
) { block(this@action) }
) {
block(env)
}
}
}
@ -150,10 +154,11 @@ class TaskBuilder<R : Any>(val name: Name, val type: KClass<out R>) {
crossinline block: ReduceGroupBuilder<T, R>.(TaskEnv) -> Unit //TODO needs KEEP-176
) {
action(from, to) {
val env = this
ReduceAction(
inputType = T::class,
outputType = type
) { block(this@action) }
) { block(env) }
}
}
@ -189,10 +194,11 @@ class TaskBuilder<R : Any>(val name: Name, val type: KClass<out R>) {
crossinline block: SplitBuilder<T, R>.(TaskEnv) -> Unit //TODO needs KEEP-176
) {
action(from, to) {
val env = this
SplitAction(
inputType = T::class,
outputType = type
) { block(this@action) }
) { block(env) }
}
}