Skip to content

Commit f7eaf93

Browse files
committed
fix: invalid casts in FlowItem
1 parent 0ce4deb commit f7eaf93

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/main/kotlin/dev/silenium/libs/flows/api/FlowItem.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ data class FlowItem<T, P>(val pad: UInt, val metadata: P, val value: T) : Refere
1717
* If value and/or metadata are [Reference], they are cloned as well.
1818
*/
1919
@Suppress("UNCHECKED_CAST")
20-
override fun clone(): Result<FlowItem<T, P>> {
20+
override fun clone(): Result<FlowItem<T, P>> = runCatching {
2121
val clonedValue = when (value) {
22-
is Reference<*> -> value.clone() as T
22+
is Reference<*> -> value.clone().getOrThrow() as T
2323
else -> value
2424
}
2525
val clonedMetadata = when (metadata) {
26-
is Reference<*> -> metadata.clone() as P
26+
is Reference<*> -> metadata.clone().getOrThrow() as P
2727
else -> metadata
2828
}
29-
return Result.success(FlowItem(pad, clonedMetadata, clonedValue))
29+
FlowItem(pad, clonedMetadata, clonedValue)
3030
}
3131

3232
/**

0 commit comments

Comments
 (0)