From 706521a6b6072517ee6d070e821e5d000b69a782 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Tue, 24 Oct 2023 10:52:41 +0300 Subject: [PATCH] Suppress manual cast warnings in task builders --- .../kotlin/space/kscience/dataforge/io/ioMisc.kt | 2 +- .../space/kscience/dataforge/meta/SealedMeta.kt | 2 +- .../kscience/dataforge/workspace/taskBuilders.kt | 16 +++++++++++----- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/dataforge-io/src/commonMain/kotlin/space/kscience/dataforge/io/ioMisc.kt b/dataforge-io/src/commonMain/kotlin/space/kscience/dataforge/io/ioMisc.kt index 4e4a7ff7..93fd210a 100644 --- a/dataforge-io/src/commonMain/kotlin/space/kscience/dataforge/io/ioMisc.kt +++ b/dataforge-io/src/commonMain/kotlin/space/kscience/dataforge/io/ioMisc.kt @@ -172,7 +172,7 @@ public fun Source.discardLine( /** * A [Source] based on [ByteArray] */ -public class ByteArraySource( +internal class ByteArraySource( private val byteArray: ByteArray, private val offset: Int = 0, private val size: Int = byteArray.size - offset, diff --git a/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/SealedMeta.kt b/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/SealedMeta.kt index 05626368..1efec0f1 100644 --- a/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/SealedMeta.kt +++ b/dataforge-meta/src/commonMain/kotlin/space/kscience/dataforge/meta/SealedMeta.kt @@ -50,7 +50,7 @@ public fun Meta(value: Boolean): SealedMeta = Meta(value.asValue()) /** - * A lightweight mutable meta used to create [SealedMeta] instances without bothering with + * A lightweight mutable meta without an observability */ @PublishedApi internal class MetaBuilder( diff --git a/dataforge-workspace/src/commonMain/kotlin/space/kscience/dataforge/workspace/taskBuilders.kt b/dataforge-workspace/src/commonMain/kotlin/space/kscience/dataforge/workspace/taskBuilders.kt index 09791d15..bf3d5921 100644 --- a/dataforge-workspace/src/commonMain/kotlin/space/kscience/dataforge/workspace/taskBuilders.kt +++ b/dataforge-workspace/src/commonMain/kotlin/space/kscience/dataforge/workspace/taskBuilders.kt @@ -33,9 +33,12 @@ public suspend inline fun TaskResultBuild dependencyMeta: Meta = defaultDependencyMeta, selectorBuilder: P.() -> TaskReference, ): DataSet { - require(workspace.context.plugins.contains(plugin)){"Plugin $plugin is not loaded into $workspace"} + require(workspace.context.plugins.contains(plugin)) { "Plugin $plugin is not loaded into $workspace" } val taskReference: TaskReference = plugin.selectorBuilder() - return workspace.produce(plugin.name + taskReference.taskName, dependencyMeta) as TaskResult + val res = workspace.produce(plugin.name + taskReference.taskName, dependencyMeta) + //TODO add explicit check after https://youtrack.jetbrains.com/issue/KT-32956 + @Suppress("UNCHECKED_CAST") + return res as TaskResult } /** @@ -45,7 +48,7 @@ public suspend inline fun TaskResultBuild * @param dependencyMeta meta used for selector. The same meta is used for caching. By default, uses [defaultDependencyMeta]. * @param selectorBuilder a builder of task from the plugin. */ -public suspend inline fun TaskResultBuilder<*>.from( +public suspend inline fun TaskResultBuilder<*>.from( pluginFactory: PluginFactory

, dependencyMeta: Meta = defaultDependencyMeta, selectorBuilder: P.() -> TaskReference, @@ -53,7 +56,10 @@ public suspend inline fun TaskResultBuild val plugin = workspace.context.plugins[pluginFactory] ?: error("Plugin ${pluginFactory.tag} not loaded into workspace context") val taskReference: TaskReference = plugin.selectorBuilder() - return workspace.produce(plugin.name + taskReference.taskName, dependencyMeta) as TaskResult + val res = workspace.produce(plugin.name + taskReference.taskName, dependencyMeta) + //TODO explicit check after https://youtrack.jetbrains.com/issue/KT-32956 + @Suppress("UNCHECKED_CAST") + return res as TaskResult } public val TaskResultBuilder<*>.allData: DataSelector<*> @@ -79,7 +85,7 @@ public suspend inline fun TaskResultBuilder.pipeFr ) { from(selector, dependencyMeta).forEach { data -> val meta = data.meta.toMutableMeta().apply { - taskMeta[taskName]?.let { taskName.put(it) } + taskMeta[taskName]?.let { taskName.put(it) } dataMetaTransform(data.name) }